{"thread":{"id":"16089","subject":"jgit as a jira plugin","startedAt":"2008-10-29T23:02:26Z","lastAt":"2008-10-31T14:42:58Z","messageCount":5,"participants":["J. Longman","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"94241","messageId":"5915DAE3-7BDF-4296-9DB3-6FBEE504A317@xiplink.com","threadId":"16089","inReplyTo":null,"subject":"jgit as a jira plugin","fromName":"J. Longman","fromEmail":"longman@xiplink.com","sentAt":"2008-10-29T23:02:26Z","receivedAt":"2008-10-29T23:02:26Z","isPatch":false,"sender":{"key":"longman@xiplink.com","avatar":null},"body":"Hey there,\n\nI've integrated jgit into a plugin for the Jira Issue tracking  \nsystem.  There is more information here: http://confluence.atlassian.com/display/JIRAEXT/Jira+Git+Plugin\n\nI'm new to git, jgit and jira plugin writing, so I have a number of  \nquestions.  These are the ones I have for you:\n\n1) I noticed that there is a maven pom file.  Are you present in a  \nmaven repository?  Also any problem with embedding a working snapshot  \nin my plugin?\n2) I'd like to find out the jgit way to achieve the equivalent of 'svn  \nupdate'.  I understand that fetch can do this but being new to git, I  \ndon't really understand quite what I need yet.  The goal is to have  \ngit the latest commits from the origin before indexing.\n\nThanks for jgit - it took me a day or two to wrap my head around  \ngetting the list of files changed in a commit but otherwise its great  \nto have something that can be integrated into jira.\n\nlater, jl\n\n--\nJ. Longman\nlongman@xiplink.com\n\nThe information transmitted is intended only for the person or entity to\nwhich it is addressed and may contain confidential and/or privileged\nmaterial.  If you have received this in error, please contact the sender\nand delete this communication and any copy immediately.  Thank you.\n"},{"id":"94249","messageId":"20081029230816.GA31926@spearce.org","threadId":"16089","inReplyTo":"5915DAE3-7BDF-4296-9DB3-6FBEE504A317@xiplink.com","subject":"Re: jgit as a jira plugin","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-29T23:08:16Z","receivedAt":"2008-10-29T23:08:16Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"J. Longman\" <longman@xiplink.com> wrote:\n> I've integrated jgit into a plugin for the Jira Issue tracking system.  \n> There is more information here: \n> http://confluence.atlassian.com/display/JIRAEXT/Jira+Git+Plugin\n\nCool!\n\n> 1) I noticed that there is a maven pom file.  Are you present in a maven \n> repository?  Also any problem with embedding a working snapshot in my \n> plugin?\n\nNo, we aren't hosted in any repository yet.  The pom file exists to\nmake it easier for people who prefer maven to build, but its not the\nprimary build system for jgit.\n\n> 2) I'd like to find out the jgit way to achieve the equivalent of 'svn  \n> update'.  I understand that fetch can do this but being new to git, I  \n> don't really understand quite what I need yet.  The goal is to have git \n> the latest commits from the origin before indexing.\n\nUse a Transport instance to execute a default fetch (no args) on say\nthe \"remote\" origin.  That will download the objects to the local\ndatabase, but it won't update a working directory.  But I'm not sure\nyou would care about the working directory in the backend of Jira.\n\n> Thanks for jgit - it took me a day or two to wrap my head around getting \n> the list of files changed in a commit but otherwise its great to have \n> something that can be integrated into jira.\n\nYea, about that, we wanted to write more tutorials on the API...  ;-)\n\n-- \nShawn.\n"},{"id":"94254","messageId":"D7D18CE8-BDBD-430A-BCB6-D1BEFD21C949@xiplink.com","threadId":"16089","inReplyTo":"20081029230816.GA31926@spearce.org","subject":"Re: jgit as a jira plugin","fromName":"J. Longman","fromEmail":"longman@xiplink.com","sentAt":"2008-10-29T23:49:47Z","receivedAt":"2008-10-29T23:49:47Z","isPatch":false,"sender":{"key":"longman@xiplink.com","avatar":null},"body":"\nOn 29-Oct-08, at 7:08 PM, Shawn O. Pearce wrote:\n> \"J. Longman\" <longman@xiplink.com> wrote:\n>> 2) I'd like to find out the jgit way to achieve the equivalent of  \n>> 'svn\n>> update'.  I understand that fetch can do this but being new to git, I\n>> don't really understand quite what I need yet.  The goal is to have  \n>> git\n>> the latest commits from the origin before indexing.\n> Use a Transport instance to execute a default fetch (no args) on say\n> the \"remote\" origin.  That will download the objects to the local\n> database, but it won't update a working directory.  But I'm not sure\n> you would care about the working directory in the backend of Jira.\n\nBasically I stole the pgm.Fetch code:\n\nTransport tn = Transport.open(repository, \"origin\");\nfinal FetchResult r;\nList<RefSpec> toget = new ArrayList<RefSpec>();\ntry {\n\tr = tn.fetch(new TextProgressMonitor(), toget);\n} finally {\n\ttn.close();\n}\n\nCan I assume that this enough to update the database?  If so I think  \nI'm doing what you're suggesting.  After this (and not shown) is some  \nlogging code taken from Fetch, which results in the following:\n\n From /Users/longman/workspace2/work/../masterRepo/\n     131dcf5..078d43f  master     -> origin/master\n\nbut there doesn't appear to be any specific mention of the incoming  \nchanges.\n\n>> Thanks for jgit - it took me a day or two to wrap my head around  \n>> getting\n>> the list of files changed in a commit but otherwise its great to have\n>> something that can be integrated into jira.\n> Yea, about that, we wanted to write more tutorials on the API...  ;-)\n\n\nWell, the egit does provide some examples, just there's another API  \ninvolved which can be confusing.  The code in the jira git plugin the  \nkey classes are GitManagerImpl and RevisionIndexer, but the  \nRevisionIndexer has some Lucene (text search engine) API mixed-in.  \nPlus I'm still even learning about git much less the jgit api so I  \ncan't vouch for quality or correctness ;-).  I could snip some code  \nout and send it to you off-list for inclusion in the wiki maybe.\n\nlater, j\n\n--\nJ. Longman\nlongman@xiplink.com\n\nThe information transmitted is intended only for the person or entity to\nwhich it is addressed and may contain confidential and/or privileged\nmaterial.  If you have received this in error, please contact the sender\nand delete this communication and any copy immediately.  Thank you.\n"},{"id":"94255","messageId":"20081029235317.GC31926@spearce.org","threadId":"16089","inReplyTo":"D7D18CE8-BDBD-430A-BCB6-D1BEFD21C949@xiplink.com","subject":"Re: jgit as a jira plugin","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-29T23:53:17Z","receivedAt":"2008-10-29T23:53:17Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"J. Longman\" <longman@xiplink.com> wrote:\n> Basically I stole the pgm.Fetch code:\n>\n> Transport tn = Transport.open(repository, \"origin\");\n> final FetchResult r;\n> List<RefSpec> toget = new ArrayList<RefSpec>();\n> try {\n> \tr = tn.fetch(new TextProgressMonitor(), toget);\n> } finally {\n> \ttn.close();\n> }\n>\n> Can I assume that this enough to update the database?\n\nYes\n\n> After this (and not shown) is some  \n> logging code taken from Fetch, which results in the following:\n>\n> From /Users/longman/workspace2/work/../masterRepo/\n>     131dcf5..078d43f  master     -> origin/master\n>\n> but there doesn't appear to be any specific mention of the incoming  \n> changes.\n\nWell, the new changes are what \"git log 131dcf5..078d43f\" outputs.\n\n-- \nShawn.\n"},{"id":"94407","messageId":"20081031144258.GS14786@spearce.org","threadId":"16089","inReplyTo":"C9B1B0D7-6F99-48DE-8593-A13F1187ADE2@xiplink.com","subject":"Re: jgit as a jira plugin","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-31T14:42:58Z","receivedAt":"2008-10-31T14:42:58Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"\"J. Longman\" <longman@xiplink.com> wrote:\n> Right, I see now, I thought there was going to be more detail.  Anyways, \n> I'm wondering if there is some action required to ensure it reads from \n> the database vs. the working directory?  I'm assuming it is still looking \n> at the workspace as this is what I'm seeing:\n>\n> ...RevisionIndexer] Latest indexed revision for repository=1 is :  \n> 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503\n> ...GitManagerImpl] Fetch...\n> ...GitManagerImpl] From /Users/longman/workspace2/work/../masterRepo/\n> ...GitManagerImpl]    c209b0f..594e8ff  master     -> origin/master\n> ...GitManagerImpl] scan for repo changes...  \n> repository.scanForRepoChanges();\n> ...GitManagerImpl] scan for repo changes... complete\n> ...RevisionIndexer] testing 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503 at \n> CORE-23 sdjskl\n> ...RevisionIndexer] \tupdate latest as  \n> 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503 at Wed Oct 29 18:49:54 EDT 2008\n\nOh.\n\nYour RevisionIndexer must be looking at HEAD, which is the current\nbranch data.  However the fetch process updated the remote tracking\nrefs, which are in a different namespace.\n\nYou should point your indexer at \"origin/master\", or use a bare\nrepository (one with no working directory) and fetch directly into\n\"refs/heads/*\" instead of into \"refs/remotes/origin/*\", that way\nthe indexer can look at branch \"master\".\n\nFetch doesn't ever touch the working directory; it only updates\nthe database in the background and the refs/remotes/ namespace so\nthat other applications can see the data that was transferred and\nchoose how to process it.\n\nIn command line Git \"git pull\" uses \"git fetch\" to get the data\nand then uses the received data to update the working directory.\nBut a lot of workflows also will just issue \"git fetch\" on their own\nto get the data, then examine it with \"gitk --all\", or do nothing\nat all because they are mirroring the data, or have to close their\nlaptop and catch a bus, etc...\n\nIf all you are doing is scanning the revision history and the\nfiles via JGit you just have to run a Transport.fetch() call and\nthen look at the refs that were updated during that call.  See the\nFetchResult object you get returned for the list; it is what the\npgm.Fetch class uses to display the output cited above.\n\n-- \nShawn.\n"}]}