forked from forgejo/forgejo
Add unit tests for update git hook
- Add unit tests. - Handle the 'impossible' case of not enough arguments. - Ref: https://codeberg.org/forgejo/forgejo/pulls/2834
This commit is contained in:
parent
0a51ae26bc
commit
dad799fa46
2 changed files with 58 additions and 22 deletions
|
@ -302,8 +302,12 @@ func runHookUpdate(c *cli.Context) error {
|
|||
ctx, cancel := installSignals()
|
||||
defer cancel()
|
||||
|
||||
// The last three arguments given to the hook are in order: reference name, old commit ID and new commit ID.
|
||||
args := os.Args[len(os.Args)-3:]
|
||||
if c.NArg() != 3 {
|
||||
return nil
|
||||
}
|
||||
args := c.Args().Slice()
|
||||
|
||||
// The arguments given to the hook are in order: reference name, old commit ID and new commit ID.
|
||||
refFullName := git.RefName(args[0])
|
||||
newCommitID := args[2]
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue