First time setting up Gerrit ... how to configure existing Git repositories that are remote thru firewall

6,850 views
Skip to first unread message

Michael Norman

unread,
Sep 8, 2011, 10:57:45 PM9/8/11
to repo-d...@googlegroups.com
Subject pretty much says it all.

I can connect via (ssh) command-line and see what 'Add Project' wants, but I can't figure out
how to add a remote repository, especially one that requires 'special' configuration 'cause
I gotta tunnel thru our corporate firewall to get to it.

Any help would be greatly appreciated,

Mike Norman

Magnus Bäck

unread,
Sep 9, 2011, 1:35:17 AM9/9/11
to repo-d...@googlegroups.com
On Friday, September 09, 2011 at 04:57 CEST,
Michael Norman <mwno...@gmail.com> wrote:

> Subject pretty much says it all.
>
> I can connect via (ssh) command-line and see what 'Add Project' wants,
> but I can't figure out
> how to add a remote repository, especially one that requires 'special'
> configuration 'cause
> I gotta tunnel thru our corporate firewall to get to it.

What do you mean by remote repository? All projects (gits) added to
a Gerrit installation are local. There's no way to connect Gerrit to
a git stored elsewhere. What you can do is create a local git as a
clone of another git and set up a job to mirror the remote git to
your git.

Anyway, please state the original problem that led you to want to
add a remote repository. "I want to add a remote repository" isn't
a problem, it's a solution to a problem.

--
Magnus Bäck Opinions are my own and do not necessarily
SW Configuration Manager represent the ones of my employer, etc.
Sony Ericsson

Michael Norman

unread,
Sep 9, 2011, 10:21:28 AM9/9/11
to repo-d...@googlegroups.com
Hmm, I guess I didn't understand that part of the docs.

So I clone an existing repo into Gerrit's directory $gerrit.basePath:

   git clone ssh://git.eclipse.org/gitroot/eclipselink/sandbox.git

Do I need to use 'gerrit create-project' (via command-line over ssh) of the same name?

Or do I have to use 'gerrit gsql' to manually insert the project?
  INSERT INTO projects
    (use_contributor_agreements
     ,submit_type
     ,name)
  VALUES
    ('N'
    ,'M'
    ,'sandbox');



Magnus Bäck

unread,
Sep 9, 2011, 10:55:37 AM9/9/11
to repo-d...@googlegroups.com
On Friday, September 09, 2011 at 16:21 CEST,
Michael Norman <mwno...@gmail.com> wrote:

> Hmm, I guess I didn't understand that part of the docs.
>
> So I clone an existing repo into Gerrit's directory $gerrit.basePath:
>
> git clone ssh://git.eclipse.org/gitroot/eclipselink/sandbox.git

You need to make it a bare git with the --bare option.

> Do I need to use 'gerrit create-project' (via command-line over ssh)
> of the same name?

I wouldn't expect that to work since the git will already exist on the
server.

> Or do I have to use 'gerrit gsql' to manually insert the project?

That's another option I guess. I would've just created an empty git on
the server (with the create-project command), then cloned the upstream
git on a client and pushed its contents to Gerrit.

I'm not sure, but I think you can re-init Gerrit to have it import
the existing projects it finds.

[...]

Deniz Türkoglu

unread,
Sep 9, 2011, 10:26:01 AM9/9/11
to repo-d...@googlegroups.com
On Fri, Sep 9, 2011 at 4:21 PM, Michael Norman <mwno...@gmail.com> wrote:
Hmm, I guess I didn't understand that part of the docs.

So I clone an existing repo into Gerrit's directory $gerrit.basePath:

   git clone ssh://git.eclipse.org/gitroot/eclipselink/sandbox.git

Do a bare clone, you don't need a working copy in gerrit and it causes problems. 


Do I need to use 'gerrit create-project' (via command-line over ssh) of the same name?

During installation point it to the directory where your clone(s) are hosted when asked, they need to be something like:

project1.git, project2.git 

Or do I have to use 'gerrit gsql' to manually insert the project?

And accept when it asks to import existing projects. I believe pretty much everything I said is in documents?!?
 
-deniz
  INSERT INTO projects
    (use_contributor_agreements
     ,submit_type
     ,name)
  VALUES
    ('N'
    ,'M'
    ,'sandbox');

Michael Norman

unread,
Sep 9, 2011, 10:11:01 PM9/9/11
to repo-d...@googlegroups.com
I finally 'cracked' it!

I ran the installation as usual - and then under the ${gerrit.basePath}/git I cloned my existing repository:
however, I need to do it in 'bare' mode, without a staging directory:

   git clone --mirror ssh://some_machine/path/to/favourite/project.git project.git

There is a bug that I understand will be fixed in 2.2.2 - but until then, you have to manually
'fix' the meta-data ref:

   prompt > cd ${gerrit.basePath}/git/project.git/refs
   prompt > mkdir meta

   prompt > cd ${gerrit.basePath}/git
   prompt > mkdir tmp
   prompt > cd tmp
   prompt > git init
   prompt > touch project.config
   prompt > git add project.config
   prompt > git commit -m "Initially empty project.config" 
   prompt > git push ../project.git/ HEAD:refs/meta/config

NB - the ${gerrit.basePath}/git/project.git directory must end in '.git' or Gerrit won't pick up
the new project when the cache is flushed:

    ssh -p 29418 gerrit-host gerrit flush-caches projects

I now have all the project's history, but subsequent commits can go thru the Gerrit review process

---
Mike Norman
Reply all
Reply to author
Forward
0 new messages