Page MenuHomePhabricator

/tools/hooks/commit-msg is missing for HTTPS remote URL
Closed, ResolvedPublic

Description

1Traceback (most recent call last):
2 File "/usr/local/bin/git-review", line 11, in <module>
3 sys.exit(main())
4 File "/usr/local/lib/python2.7/dist-packages/git_review/cmd.py", line 1202, in main
5 set_hooks_commit_msg(remote, hook_file)
6 File "/usr/local/lib/python2.7/dist-packages/git_review/cmd.py", line 264, in set_hooks_commit_msg
7 res = run_http_exc(CannotInstallHook, hook_url, stream=True)
8 File "/usr/local/lib/python2.7/dist-packages/git_review/cmd.py", line 175, in run_http_exc
9 raise klazz(255, str(err), ('GET', url), env)
10git_review.cmd.CannotInstallHook: Problems encountered installing commit-msg hook
11The following command failed with exit code 255
12 "GET https://gerrit.wikimedia.org/tools/hooks/commit-msg"
13-----------------------
14Problems encountered installing commit-msg hook
15The following command failed with exit code 104
16 "GET https://gerrit.wikimedia.org/tools/hooks/commit-msg"
17-----------------------
18<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
19<html><head>
20<title>404 Not Found</title>
21</head><body>
22<h1>Not Found</h1>
23<p>The requested URL /tools/hooks/commit-msg was not found on this server.</p>
24</body></html>
25
26-----------------------
27-----------------------

This is with any HTTPS remote URL. It's happy if I set the remote URL to SSH instead.

Workaround:

In the mediawiki-core directory,

cd .git/hooks
wget https://gerrit.wikimedia.org/r/tools/hooks/commit-msg
chmod 755 commit-msg

will install the commit-msg hook.

Everything should work afterwards. Note, however, that the password for pushing is not your normal password, but the one listed under https://gerrit.wikimedia.org/r/#/settings/http-password .

Event Timeline

Krenair raised the priority of this task from to Needs Triage.
Krenair updated the task description. (Show Details)
Krenair added a project: Gerrit.
Krenair added subscribers: Krenair, Negative24.
Krenair set Security to None.

The remote URL looks wrong. It should be https://gerrit.wikimedia.org/r/tools/hooks/commit-msg (Note the /r/ in the path).

However ... I cannot reproduce your issue.
When cloning through https, git-review is smart enough to figure things out for me:

_________________________________________________________________
christian@spencer // jobs: 0 // time: 19:32:58 // exit code: 0
cwd: ~/sources/Wikimedia/gerrit/EventLogging
git-review --version
git-review version 1.24.post51

_________________________________________________________________
christian@spencer // jobs: 0 // time: 19:33:01 // exit code: 0
cwd: ~/sources/Wikimedia/gerrit
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging
Cloning into 'EventLogging'...
remote: Counting objects: 215, done
remote: Finding sources: 100% (43/43)
remote: Getting sizes: 100% (31/31)
remote: Compressing objects: 100% (57301/57301)
remote: Total 3888 (delta 6), reused 3861 (delta 5)
Receiving objects: 100% (3888/3888), 805.66 KiB | 357 KiB/s, done.
Resolving deltas: 100% (2448/2448), done.

_________________________________________________________________
christian@spencer // jobs: 0 // time: 19:33:08 // exit code: 0
cwd: ~/sources/Wikimedia/gerrit
cd EventLogging/

_________________________________________________________________
christian@spencer // jobs: 0 // time: 19:33:11 // exit code: 0
cwd: ~/sources/Wikimedia/gerrit/EventLogging
git review -s
Could not connect to gerrit.
Enter your gerrit username: qchris
Trying again with ssh://qchris@gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging.git
Creating a git remote called "gerrit" that maps to:
        ssh://qchris@gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging.git

This repository is now set up for use with git-review. You can set the
default username for future repositories with:
  git config --global --add gitreview.username "qchris"


_________________________________________________________________
christian@spencer // jobs: 0 // time: 19:33:26 // exit code: 0
cwd: ~/sources/Wikimedia/gerrit/EventLogging
ll .git/hooks/commit-msg
-rwxr-xr-x 1 christian users 4376 Mar 22 19:33 .git/hooks/commit-msg*

Which version of git-review are you running, and which repo are you experiencing the issue with?

I've experienced this with every repo I had configured to use HTTPS rather than SSH.

alex@alex-laptop:~$ git-review --version
git-review version 1.24

I've experienced this with every repo I had configured to use HTTPS rather than SSH.

The above commands start with a https clone and lets git-review setup what it needs (like switching to SSH).

So by 'configured to use HTTPS' you mean you either forcing a HTTPS remote (like using -r ...)?

I guess you're on your own then. git-review fails to figure out to add a /r/ to the URL (which is needed by WMF reverse proxy setup).

https://review.openstack.org/gitweb?p=openstack-infra/git-review.git;a=blob;f=git_review/cmd.py;h=3abf3271866817eafeb3985fe56697d4da6eab5f;hb=79262a52301c146a6b60d09a828661a83a5f5ba7#l312

I guess one either needs to setup a forward from

https://gerrit.wikimedia.org/tools/hooks/commit-msg

to

https://gerrit.wikimedia.org/r/tools/hooks/commit-msg

, or fix git-review itself to figure out about adding the /r/.

Aklapper renamed this task from /tools/hooks/commit-msg is missing to /tools/hooks/commit-msg is missing for HTTPS remote URL.Mar 23 2015, 10:54 AM
Aklapper triaged this task as Lowest priority.

After having used a local installation for a while, I tried a new one using Vagrant and found this problem. In the ticket comments there seem to be some references to workarounds, but a more detailed description of how to apply it would be helpful.

@Pginer-WMF:

In the mediawiki-core directory,

cd .git/hooks
wget https://gerrit.wikimedia.org/r/tools/hooks/commit-msg
chmod 755 commit-msg

will install the commit-msg hook. I think that's the only git-review speed bump for https (other than that you have to use the right password, namely the one listed under https://gerrit.wikimedia.org/r/#/settings/http-password ).

Paladox claimed this task.
Paladox added a subscriber: Paladox.

Can this be closed since the rewrite rule was added to gerrit apache. It should work on the old gerrit and the new gerrit now.

Oh woops, sorry I didn't mean to close it but anyways seems to be resolved and the rewrite rule added. Please reopen if the problem still happends.