mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
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
(cherry picked from commit dad799fa46
)
This commit is contained in:
parent
52d217ec50
commit
d4a4b4b4e3
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