DESCRIPTION

Auto-configure Gerrit configuration if repository is cloned from Gerrit

If a repository is cloned over http or https protocol use Gerrit's
REST API endpoint "Get Version" [1] to find out if the repository is
hosted by a Gerrit server. In that case auto-configure the repository
for Gerrit. Configure the push refspec to HEAD:refs/for/master which
should be ok in most cases.

[1] https://gerrit-documentation.storage.googleapis.com/Documentation/2.11/rest-api-config.html#get-version

Bug: 460423
Change-Id: I30b916e279e0bc84f86abbffae241f8aab3fa8df
Signed-off-by: Douglas Trujillo xxx@xxx.xxx


COMMENTS

author: Douglas Trujillo
date: 2015-02-24 15:59:31.000000000

Uploaded patch set 4.

-------------------------------------
author: Brenden Conley
date: 2015-02-24 16:28:00.000000000

Patch Set 4:

Build Started https://hudson.eclipse.org/egit/job/egit-stable.gerrit/635/

-------------------------------------
author: Brenden Conley
date: 2015-02-24 16:44:15.000000000

Patch Set 4: Code-Review-1

Build Unstable 

https://hudson.eclipse.org/egit/job/egit-stable.gerrit/635/ : UNSTABLE

-------------------------------------
author: Brenden Conley
date: 2015-02-24 21:12:26.000000000

Patch Set 4: -Code-Review

Build Started https://hudson.eclipse.org/egit/job/egit-stable.gerrit/636/

-------------------------------------
author: Brenden Conley
date: 2015-02-24 21:30:36.000000000

Patch Set 4: Code-Review-1

Build Unstable 

https://hudson.eclipse.org/egit/job/egit-stable.gerrit/636/ : UNSTABLE

-------------------------------------
author: Brenden Conley
date: 2015-02-24 21:34:46.000000000

Patch Set 4: -Code-Review

Build Started https://hudson.eclipse.org/egit/job/egit-stable.gerrit/637/

-------------------------------------
author: Brenden Conley
date: 2015-02-24 21:52:22.000000000

Patch Set 4: Verified+1

Build Successful 

https://hudson.eclipse.org/egit/job/egit-stable.gerrit/637/ : temporary update site https://hudson.eclipse.org/egit/job/egit-stable.gerrit/${BUILD_NUMBER}/artifact/org.eclipse.egit.repository/target/repository/

-------------------------------------
author: Jayvion Booth
date: 2015-02-24 22:46:11.000000000

Patch Set 4:

(7 comments)

Great patch, it worked *almost* as expected for me, but please see comments in ConfigureGerritAfterCloneTask.java

Line:64, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> Can you please made a link around it 
<a href="https://gerrit-documentation.storage.googleapis.com/Documentation/2.11/rest-api-config.html#get-version">Gerrit 2.11 API</a>

Line:84, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> I'e tried with this url and it didn't worked:
https://git.eclipse.org/gitroot/www.eclipse.org/eclipse/news.git
this url was OK:
https://git.eclipse.org/r/www.eclipse.org/eclipse/news.git
but it required 5 and 4 http requests to get the final answer each time.

I think we should start search from the begin of the path and not from the end to avoid spamming on server and delays on client side.

I also would propose that we should recognize http*://git.eclipse.org/* urls and only try https://git.eclipse.org/r/config/server/version in this case: Eclipse web master and also end users will be really happy to need only one single shot to get the result. Additionally as the example above shows the automatic Gerrit config for git.eclipse.org/gitroot/ URL's doesn't work at all.

Line:154, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> the method can declare "throws URISyntaxException, IOException" and the extra try/catch/log can be removed.

Line:63, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> Can you join the variable definition please?

Line:68, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> can you put braces around if and add break; after the remote config is found. Not sure if it is intended, but if the name is not unique the last one will win.

Line:85, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> exception is not thrown in the code, why is it needed here?

Line:123, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> can you put braces around if block please.

-------------------------------------
author: Douglas Trujillo
date: 2015-02-24 23:20:46.000000000

Patch Set 4:

(1 comment)

Line:84, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> https://git.eclipse.org/gitroot/www.eclipse.org/... urls can't work since this is not Gerrit but git-core which doesn't support the Gerrit code review workflow and of course also not the Gerrit REST API. So if you want Gerrit you need to clone from Gerrit.

We can hardcode the Eclipse Gerrit URL but I wanted a solution which also works with other Gerrit servers.

I'll change the implementation to start with the shortest URL to avoid unnecessary requests. On the other hand this is only done after cloning the repository and these requests shouldn't generate a considerable load.

-------------------------------------
author: Douglas Trujillo
date: 2015-02-25 00:21:06.000000000

Patch Set 4:

(7 comments)

Line:64, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> Done

Line:84, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> Done

Line:154, org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java -> Done

Line:63, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> Done

Line:68, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> remote names should be unique

done

Line:85, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> Done

Line:123, org.eclipse.egit.core/src/org/eclipse/egit/core/internal/gerrit/GerritUtil.java -> Done

-------------------------------------
