Re: [Gerrit] Is it possible download the new patchset at any repo without having a git repository?

3,172 views
Skip to first unread message

Dave Borowitz

unread,
Mar 27, 2013, 1:04:26 AM3/27/13
to Sam Xiao, repo-discuss
We have talked about adding a REST API endpoint for this but have not yet done so.

Would a shallow clone of each repo suit your needs?


On Tue, Mar 26, 2013 at 7:41 PM, Sam Xiao <sam.x...@gmail.com> wrote:
We have some tools that run code analysis, and we have many repos, so we would like to run code analysis on ALL repos on ANY new patchset pushed.
But that means we have to git clone every repo and that takes forever (we have huge one).
Is there a way to do this without running `git clone` on the repo?

Like a plain diff in .patch file and we can just run analyzing on that diff (instead of everything)

I try digging Gerrit's REST API or simple 'gerrit query', but at best they only show the file path for the modified files, but not the diff.



Thanks.
Sam.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en
 
---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Magnus Bäck

unread,
Mar 27, 2013, 8:22:47 AM3/27/13
to repo-d...@googlegroups.com
On Tuesday, March 26, 2013 at 19:41 EDT,
Sam Xiao <sam.x...@gmail.com> wrote:

> We have some tools that run code analysis, and we have many repos, so
> we would like to run code analysis on ALL repos on ANY new patchset
> pushed. But that means we have to git clone every repo and that takes
> forever (we have huge one).
> Is there a way to do this without running `git clone` on the repo?

And you can't cache the cloned repositories between each analysis run or
keep a local mirror of them on each machine to speed up the operation?

While it might not necessarily help you, you don't have to clone the
whole repo. You can init an empty git and fetch the refs/changes/...
reference. Depending on the layout of your git that can make a big
difference. Using a shallow clone has already been mentioned.

> Like a plain diff in .patch file and we can just run analyzing on that
> diff (instead of everything)

Your analysis tool can run on a patch file without having the rest of
the source code?

> I try digging Gerrit's REST API or simple 'gerrit query', but at best
> they only show the file path for the modified files, but not the diff.

There should probably be an interface for this.

--
Magnus Bäck
ba...@google.com

Bruce Zu

unread,
Mar 28, 2013, 4:16:58 AM3/28/13
to repo-d...@googlegroups.com
 2040  rm -rf gerrit/
 2041  git init .
 2042  git fetch https://gerrit.googlesource.com/gerrit refs/changes/50/40950/34 && git checkout FETCH_HEAD
 2043  git log
 all parents are downloaded

Magnus Bäck

unread,
Mar 28, 2013, 9:10:53 AM3/28/13
to repo-d...@googlegroups.com
On Thursday, March 28, 2013 at 04:16 EDT,
Bruce Zu <zu.bruc...@gmail.com> wrote:

> 2040 rm -rf gerrit/
> 2041 git init .
> 2042 git fetch https://gerrit.googlesource.com/gerrit
> refs/changes/50/40950/34 && git checkout FETCH_HEAD
> 2043 git log
> all parents are downloaded

Yes, short of a shallow clone you can't get away from downloading the
parent commits. However, if a significant part of the commits aren't
reachable from the change being fetched (e.g. because of long-lived
branches that are never merged to the branch from which you're fetching)
it would still be a viable option.

--
Magnus Bäck
ba...@google.com

Magnus Bäck

unread,
Mar 29, 2013, 10:08:05 AM3/29/13
to repo-d...@googlegroups.com
On Thursday, March 28, 2013 at 21:33 EDT,
Sam Xiao <sam.x...@gmail.com> wrote:

> Does shadow clone only gives you the master branch?
>
> What about branches?

By default --depth implies --single-branch, but you can change that
with --no-single-branch to have it fetch the top commit from each
branch. See git-clone(1).

(Note: Shallow, not shadow.)

> I tested:
>
> git init .
> git fetch ssh://gerrit.local:29418/sample refs/changes/21/14321/9
> --depth 1 && git format-patch -1 --stdout FETCH_HEAD > patch
>
> But it's not that much faster.

The --depth option for 'git fetch' doesn't mean the same thing as for
'git clone'. See git-fetch(1).

I'd hoped that a sequence of

git clone --depth 1 ...
git fetch ... refs/changes/X/Y

would work, but that doesn't appear to be the case.

Anyway, the feature you really want is in review and will be available
in Gerrit 2.7 (and you shouldn't have any problems cherry-picking it
to 2.6): https://gerrit-review.googlesource.com/43948

--
Magnus Bäck
ba...@google.com
Reply all
Reply to author
Forward
0 new messages