How to set the value of gerrit.installCommitMsgHookCommand?

222 views
Skip to first unread message

Yingchun Li

unread,
Jun 7, 2023, 2:05:15 AM6/7/23
to Repo and Gerrit Discussion
Hi, Teams
     I upgrade the gerrit from 3.4.8->3.7.3, the default command to download the 
hook commit-msg changed, now it is 

git clone "ssh://myname@git-server:29418/All-Projects" && (cd "All-Projects" && mkdir -p `git rev-parse --git-dir`/hooks/ && curl -Lo `git rev-parse --git-dir`/hooks/commit-msg http://git-server/tools/hooks/commit-msg && chmod +x `git rev-parse --git-dir`/hooks/commit-msg)
    The problems with curl is that it doesn't prompt the user to input username and password, and just download a wrong file like this:
"
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>401 Unauthorized</title>
</head><body>
<h1>Unauthorized</h1>
<p>This server could not verify that you
are authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.</p>
<hr>
<address>Apache/2.4.41 (Ubuntu) Server at git-server Port 80</address>
</body></html>
"
So I want to change back the value of "gerrit.installCommitMsgHookCommand" to
3.4.8, which use scp command.
 Please give an example, thanks a lot.
Br,
Yingchun

Yingchun Li

unread,
Jun 8, 2023, 3:34:54 AM6/8/23
to Repo and Gerrit Discussion
I checked the source code, and  can set the download coomand using:

gitdir=$(git rev-parse --git-dir); scp -p -P %d %s@%s:hooks/commit-msg ${gitdir}/hooks/"

But how can I get the username and website in the gerrit.config? are there environment
variables I can use?

One more thing,  Is this a bug? For every choice in the download page,like 
"ANONYMOUSE HTTP", "HTTP", "SSH", all the commit-msg downloading command
is curl, no ssh.

Matthias Sohn

unread,
Jun 8, 2023, 12:37:43 PM6/8/23
to Yingchun Li, Repo and Gerrit Discussion
On Thu, Jun 8, 2023 at 9:34 AM Yingchun Li <sword.l...@gmail.com> wrote:

Please avoid top posting on this list, use interleaved style [1] instead which is easier to follow
the conversation thread.

I checked the source code, and  can set the download coomand using:

gitdir=$(git rev-parse --git-dir); scp -p -P %d %s@%s:hooks/commit-msg ${gitdir}/hooks/"

But how can I get the username and website in the gerrit.config? are there environment
variables I can use?

One more thing,  Is this a bug? For every choice in the download page,like 
"ANONYMOUSE HTTP", "HTTP", "SSH", all the commit-msg downloading command
is curl, no ssh.

to get rid of issues with diverse versions of openssh.

I think downloading the hook script shouldn't require authentication.
Which authentication method do you use?
 

-Matthias

--
--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/0d4fe503-b344-4734-b2ba-be79daf7413an%40googlegroups.com.

Yingchun Li

unread,
Jun 8, 2023, 10:39:01 PM6/8/23
to Repo and Gerrit Discussion
On Friday, June 9, 2023 at 12:37:43 AM UTC+8 Matthias Sohn wrote:
On Thu, Jun 8, 2023 at 9:34 AM Yingchun Li <sword.l...@gmail.com> wrote:

Please avoid top posting on this list, use interleaved style [1] instead which is easier to follow
the conversation thread.
OK, Sorry for that .
I checked the source code, and  can set the download coomand using:

gitdir=$(git rev-parse --git-dir); scp -p -P %d %s@%s:hooks/commit-msg ${gitdir}/hooks/"

But how can I get the username and website in the gerrit.config? are there environment
variables I can use?

One more thing,  Is this a bug? For every choice in the download page,like 
"ANONYMOUSE HTTP", "HTTP", "SSH", all the commit-msg downloading command
is curl, no ssh.

to get rid of issues with diverse versions of openssh.

I think downloading the hook script shouldn't require authentication.
Which authentication method do you use?
We just use the http, and behind of a nginx reverse proxy.

Matthias Sohn

unread,
Jun 9, 2023, 5:52:01 AM6/9/23
to Yingchun Li, Repo and Gerrit Discussion
On Fri, Jun 9, 2023 at 4:39 AM Yingchun Li <sword.l...@gmail.com> wrote:


On Friday, June 9, 2023 at 12:37:43 AM UTC+8 Matthias Sohn wrote:
On Thu, Jun 8, 2023 at 9:34 AM Yingchun Li <sword.l...@gmail.com> wrote:

Please avoid top posting on this list, use interleaved style [1] instead which is easier to follow
the conversation thread.
OK, Sorry for that .
I checked the source code, and  can set the download coomand using:

gitdir=$(git rev-parse --git-dir); scp -p -P %d %s@%s:hooks/commit-msg ${gitdir}/hooks/"

But how can I get the username and website in the gerrit.config? are there environment
variables I can use?

One more thing,  Is this a bug? For every choice in the download page,like 
"ANONYMOUSE HTTP", "HTTP", "SSH", all the commit-msg downloading command
is curl, no ssh.

to get rid of issues with diverse versions of openssh.

I think downloading the hook script shouldn't require authentication.
Which authentication method do you use?
We just use the http, and behind of a nginx reverse proxy.

I'd try to configure the reverse proxy to not require authentication for the URL used to download hooks.
 

Yingchun Li

unread,
Jun 12, 2023, 2:32:44 AM6/12/23
to Repo and Gerrit Discussion
On Friday, June 9, 2023 at 5:52:01 PM UTC+8 Matthias Sohn wrote:
On Fri, Jun 9, 2023 at 4:39 AM Yingchun Li <sword.l...@gmail.com> wrote:


On Friday, June 9, 2023 at 12:37:43 AM UTC+8 Matthias Sohn wrote:
On Thu, Jun 8, 2023 at 9:34 AM Yingchun Li <sword.l...@gmail.com> wrote:

Please avoid top posting on this list, use interleaved style [1] instead which is easier to follow
the conversation thread.
OK, Sorry for that .
I checked the source code, and  can set the download coomand using:

gitdir=$(git rev-parse --git-dir); scp -p -P %d %s@%s:hooks/commit-msg ${gitdir}/hooks/"

But how can I get the username and website in the gerrit.config? are there environment
variables I can use?

One more thing,  Is this a bug? For every choice in the download page,like 
"ANONYMOUSE HTTP", "HTTP", "SSH", all the commit-msg downloading command
is curl, no ssh.

to get rid of issues with diverse versions of openssh.

I think downloading the hook script shouldn't require authentication.
Which authentication method do you use?
We just use the http, and behind of a nginx reverse proxy.

I'd try to configure the reverse proxy to not require authentication for the URL used to download hooks.
Great, that works,  thank you!! 
Reply all
Reply to author
Forward
0 new messages