* jgit as a jira plugin
@ 2008-10-29 23:02 J. Longman
2008-10-29 23:08 ` Shawn O. Pearce
0 siblings, 1 reply; 5+ messages in thread
From: J. Longman @ 2008-10-29 23:02 UTC (permalink / raw)
To: git
Hey there,
I've integrated jgit into a plugin for the Jira Issue tracking
system. There is more information here: http://confluence.atlassian.com/display/JIRAEXT/Jira+Git+Plugin
I'm new to git, jgit and jira plugin writing, so I have a number of
questions. These are the ones I have for you:
1) I noticed that there is a maven pom file. Are you present in a
maven repository? Also any problem with embedding a working snapshot
in my plugin?
2) I'd like to find out the jgit way to achieve the equivalent of 'svn
update'. I understand that fetch can do this but being new to git, I
don't really understand quite what I need yet. The goal is to have
git the latest commits from the origin before indexing.
Thanks for jgit - it took me a day or two to wrap my head around
getting the list of files changed in a commit but otherwise its great
to have something that can be integrated into jira.
later, jl
--
J. Longman
longman@xiplink.com
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you have received this in error, please contact the sender
and delete this communication and any copy immediately. Thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: jgit as a jira plugin
2008-10-29 23:02 jgit as a jira plugin J. Longman
@ 2008-10-29 23:08 ` Shawn O. Pearce
2008-10-29 23:49 ` J. Longman
0 siblings, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2008-10-29 23:08 UTC (permalink / raw)
To: J. Longman; +Cc: git
"J. Longman" <longman@xiplink.com> wrote:
> I've integrated jgit into a plugin for the Jira Issue tracking system.
> There is more information here:
> http://confluence.atlassian.com/display/JIRAEXT/Jira+Git+Plugin
Cool!
> 1) I noticed that there is a maven pom file. Are you present in a maven
> repository? Also any problem with embedding a working snapshot in my
> plugin?
No, we aren't hosted in any repository yet. The pom file exists to
make it easier for people who prefer maven to build, but its not the
primary build system for jgit.
> 2) I'd like to find out the jgit way to achieve the equivalent of 'svn
> update'. I understand that fetch can do this but being new to git, I
> don't really understand quite what I need yet. The goal is to have git
> the latest commits from the origin before indexing.
Use a Transport instance to execute a default fetch (no args) on say
the "remote" origin. That will download the objects to the local
database, but it won't update a working directory. But I'm not sure
you would care about the working directory in the backend of Jira.
> Thanks for jgit - it took me a day or two to wrap my head around getting
> the list of files changed in a commit but otherwise its great to have
> something that can be integrated into jira.
Yea, about that, we wanted to write more tutorials on the API... ;-)
--
Shawn.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: jgit as a jira plugin
2008-10-29 23:08 ` Shawn O. Pearce
@ 2008-10-29 23:49 ` J. Longman
2008-10-29 23:53 ` Shawn O. Pearce
0 siblings, 1 reply; 5+ messages in thread
From: J. Longman @ 2008-10-29 23:49 UTC (permalink / raw)
To: Shawn O. Pearce; +Cc: git
On 29-Oct-08, at 7:08 PM, Shawn O. Pearce wrote:
> "J. Longman" <longman@xiplink.com> wrote:
>> 2) I'd like to find out the jgit way to achieve the equivalent of
>> 'svn
>> update'. I understand that fetch can do this but being new to git, I
>> don't really understand quite what I need yet. The goal is to have
>> git
>> the latest commits from the origin before indexing.
> Use a Transport instance to execute a default fetch (no args) on say
> the "remote" origin. That will download the objects to the local
> database, but it won't update a working directory. But I'm not sure
> you would care about the working directory in the backend of Jira.
Basically I stole the pgm.Fetch code:
Transport tn = Transport.open(repository, "origin");
final FetchResult r;
List<RefSpec> toget = new ArrayList<RefSpec>();
try {
r = tn.fetch(new TextProgressMonitor(), toget);
} finally {
tn.close();
}
Can I assume that this enough to update the database? If so I think
I'm doing what you're suggesting. After this (and not shown) is some
logging code taken from Fetch, which results in the following:
From /Users/longman/workspace2/work/../masterRepo/
131dcf5..078d43f master -> origin/master
but there doesn't appear to be any specific mention of the incoming
changes.
>> Thanks for jgit - it took me a day or two to wrap my head around
>> getting
>> the list of files changed in a commit but otherwise its great to have
>> something that can be integrated into jira.
> Yea, about that, we wanted to write more tutorials on the API... ;-)
Well, the egit does provide some examples, just there's another API
involved which can be confusing. The code in the jira git plugin the
key classes are GitManagerImpl and RevisionIndexer, but the
RevisionIndexer has some Lucene (text search engine) API mixed-in.
Plus I'm still even learning about git much less the jgit api so I
can't vouch for quality or correctness ;-). I could snip some code
out and send it to you off-list for inclusion in the wiki maybe.
later, j
--
J. Longman
longman@xiplink.com
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If you have received this in error, please contact the sender
and delete this communication and any copy immediately. Thank you.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: jgit as a jira plugin
2008-10-29 23:49 ` J. Longman
@ 2008-10-29 23:53 ` Shawn O. Pearce
[not found] ` <C9B1B0D7-6F99-48DE-8593-A13F1187ADE2@xiplink.com>
0 siblings, 1 reply; 5+ messages in thread
From: Shawn O. Pearce @ 2008-10-29 23:53 UTC (permalink / raw)
To: J. Longman; +Cc: git
"J. Longman" <longman@xiplink.com> wrote:
> Basically I stole the pgm.Fetch code:
>
> Transport tn = Transport.open(repository, "origin");
> final FetchResult r;
> List<RefSpec> toget = new ArrayList<RefSpec>();
> try {
> r = tn.fetch(new TextProgressMonitor(), toget);
> } finally {
> tn.close();
> }
>
> Can I assume that this enough to update the database?
Yes
> After this (and not shown) is some
> logging code taken from Fetch, which results in the following:
>
> From /Users/longman/workspace2/work/../masterRepo/
> 131dcf5..078d43f master -> origin/master
>
> but there doesn't appear to be any specific mention of the incoming
> changes.
Well, the new changes are what "git log 131dcf5..078d43f" outputs.
--
Shawn.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: jgit as a jira plugin
[not found] ` <C9B1B0D7-6F99-48DE-8593-A13F1187ADE2@xiplink.com>
@ 2008-10-31 14:42 ` Shawn O. Pearce
0 siblings, 0 replies; 5+ messages in thread
From: Shawn O. Pearce @ 2008-10-31 14:42 UTC (permalink / raw)
To: J. Longman; +Cc: git
"J. Longman" <longman@xiplink.com> wrote:
> Right, I see now, I thought there was going to be more detail. Anyways,
> I'm wondering if there is some action required to ensure it reads from
> the database vs. the working directory? I'm assuming it is still looking
> at the workspace as this is what I'm seeing:
>
> ...RevisionIndexer] Latest indexed revision for repository=1 is :
> 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503
> ...GitManagerImpl] Fetch...
> ...GitManagerImpl] From /Users/longman/workspace2/work/../masterRepo/
> ...GitManagerImpl] c209b0f..594e8ff master -> origin/master
> ...GitManagerImpl] scan for repo changes...
> repository.scanForRepoChanges();
> ...GitManagerImpl] scan for repo changes... complete
> ...RevisionIndexer] testing 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503 at
> CORE-23 sdjskl
> ...RevisionIndexer] update latest as
> 29ed4398d047ba5e0d6fbad9ebbf98304b0fc503 at Wed Oct 29 18:49:54 EDT 2008
Oh.
Your RevisionIndexer must be looking at HEAD, which is the current
branch data. However the fetch process updated the remote tracking
refs, which are in a different namespace.
You should point your indexer at "origin/master", or use a bare
repository (one with no working directory) and fetch directly into
"refs/heads/*" instead of into "refs/remotes/origin/*", that way
the indexer can look at branch "master".
Fetch doesn't ever touch the working directory; it only updates
the database in the background and the refs/remotes/ namespace so
that other applications can see the data that was transferred and
choose how to process it.
In command line Git "git pull" uses "git fetch" to get the data
and then uses the received data to update the working directory.
But a lot of workflows also will just issue "git fetch" on their own
to get the data, then examine it with "gitk --all", or do nothing
at all because they are mirroring the data, or have to close their
laptop and catch a bus, etc...
If all you are doing is scanning the revision history and the
files via JGit you just have to run a Transport.fetch() call and
then look at the refs that were updated during that call. See the
FetchResult object you get returned for the list; it is what the
pgm.Fetch class uses to display the output cited above.
--
Shawn.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-10-31 14:44 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-29 23:02 jgit as a jira plugin J. Longman
2008-10-29 23:08 ` Shawn O. Pearce
2008-10-29 23:49 ` J. Longman
2008-10-29 23:53 ` Shawn O. Pearce
[not found] ` <C9B1B0D7-6F99-48DE-8593-A13F1187ADE2@xiplink.com>
2008-10-31 14:42 ` Shawn O. Pearce
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).