Git hooks

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: Git hooks

Post by bantu »

Could someone adjust the client side commit message hook to also add the bug tracker link in case the branch is "ticket/$ticket_id"?

Commit message:

Code: Select all

[$type/$name]
but if $type == 'ticket' make it

Code: Select all

[ticket/$ticket_id]

PHPBB3-$ticket_id

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Git hooks

Post by igorw »

Here you go: http://github.com/evil3/phpbb3/commit/f ... 9a209617c1 (on git-tools branch)

I have only tested it on OS X. Note: the PHPBB3-$ticket_id is below the commit message comments, it was the only way to do it without having them removed.

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: Git hooks

Post by bantu »

eviL3 wrote:Here you go: http://github.com/evil3/phpbb3/commit/f ... 9a209617c1 (on git-tools branch)
Great, thanks. I shall be looking into this later.

Another thing I just thought could be useful:
Can we add a hook that warns you if your commit message is not up to the standards?

The following things can be checked as per http://wiki.phpbb.com/display/DEV/Git (line n is the last line that contains text)
  • The 1st line has to contain a branchname in [] followed by a space and some text. (E.g. "[feature/foobar] Bla bla")
  • The 1st line should not be longer than 80 characters to get useful --oneline logs
  • The 2nd line has to be empty.
  • Lines 3 till (n-2) should not be longer than 80 characters.
    Those lines could be wordwrapped automatically to 80 characters if it is possible to alter the commit message without commiting automatically.
  • The (n-1)th line has to be empty.
  • The (n)th line has to contain a ticket name (e.g. "PHPBB3-12345").
  • Hint: There might be an (n+1)th line if the (n)th line has a \n at the end.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Git hooks

Post by igorw »

Might be useful, but my sh-fu really isn't that good. Thinking of it now, perhaps the ticket ID can be appended using a commit-msg hook instead of prepare-commit-msg.

EDIT: I've done just that, it now uses a commit-msg hook.

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Git hooks

Post by igorw »

I've also added install/uninstall scripts to easily install the hooks: http://github.com/evil3/phpbb3/commit/3 ... 9d67c4ad7e

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: Git hooks

Post by bantu »

I have tried those now. The install/uninstall scripts work for me, but the new hook for the ticket name (PHPBB3-12345) does not for some reason.
I also noticed that your git-tools branch is on develop, this should go into develop-olympus in my opinion.

Is anyone else able to double check the scripts?

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: Git hooks

Post by igorw »

bantu wrote:I also noticed that your git-tools branch is on develop, this should go into develop-olympus in my opinion.
Oh yes, fixed: http://github.com/evil3/phpbb3/compare/ ... /git-tools
bantu wrote:I have tried those now. The install/uninstall scripts work for me, but the new hook for the ticket name (PHPBB3-12345) does not for some reason.
Note that it adds it AFTER you submit your commit message, you need to look at it via `git log -p`.

ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Git hooks

Post by ToonArmy »

bantu wrote:I have tried those now. The install/uninstall scripts work for me, but the new hook for the ticket name (PHPBB3-12345) does not for some reason.
I also noticed that your git-tools branch is on develop, this should go into develop-olympus in my opinion.
They should be merged into both. :P
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

User avatar
bantu
3.0 Release Manager
3.0 Release Manager
Posts: 557
Joined: Thu Sep 07, 2006 11:22 am
Location: Karlsruhe, Germany
Contact:

Re: Git hooks

Post by bantu »

eviL3 wrote:
bantu wrote:I have tried those now. The install/uninstall scripts work for me, but the new hook for the ticket name (PHPBB3-12345) does not for some reason.
Note that it adds it AFTER you submit your commit message, you need to look at it via `git log -p`.
Oh, sorry. I just read up what the "commit-msg" and the "prep-commit-msg" hooks actually are. And I think this should clearly be a "prep-commit-msg" hook. A "commit-msg" hook takes away control from the developer and will only cause confusion.

ToonArmy
Registered User
Posts: 335
Joined: Fri Mar 26, 2004 7:31 pm
Location: Bristol, UK
Contact:

Re: Git hooks

Post by ToonArmy »

I updated the hook to append the tracker ID to the commit message pre editing, it makes more sense this way and will confuse people less. I also added a line length check to the commit message hook, I'm not sure how to best approach validating syntax; I could add one giant regex but I'd rather parse over the file and highlight where the error is. See http://github.com/cs278/phpbb3/compare/ ... .git-tools
Chris SmithBlogXMOOhlohArea51WikiNo support via PM/IM
Image

Post Reply