Skip to content

Commit 86acbe1

Browse files
committed
add forced-update message
1 parent 0d9442e commit 86acbe1

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

cmd/hook.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,9 @@ Gitea or set your environment appropriately.`, "")
615615
writePktLine(os.Stdout, pktLineTypeData, []byte("option old-oid "+rs.OldOID))
616616
}
617617
writePktLine(os.Stdout, pktLineTypeData, []byte("option new-oid "+rs.NewOID))
618+
if rs.IsForcePush {
619+
writePktLine(os.Stdout, pktLineTypeData, []byte("option forced-update"))
620+
}
618621
}
619622
writePktLine(os.Stdout, pktLineTypeFlush, nil)
620623

modules/private/hook.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,12 @@ type HockProcReceiveResult struct {
8282

8383
// HockProcReceiveRefResult represents an individual result from ProcReceive
8484
type HockProcReceiveRefResult struct {
85-
OldOID string
86-
NewOID string
87-
Ref string
88-
OrignRef string
89-
Err string
85+
OldOID string
86+
NewOID string
87+
Ref string
88+
OrignRef string
89+
IsForcePush bool
90+
Err string
9091
}
9192

9293
// HookPreReceive check whether the provided commits are allowed

routers/private/hook.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -788,12 +788,14 @@ func HookProcReceive(ctx *gitea_context.PrivateContext) {
788788
notification.NotifyPullRequestPushCommits(pusher, pr, comment)
789789
}
790790
notification.NotifyPullRequestSynchronized(pusher, pr)
791+
isForcePush := comment != nil && comment.IsForcePush
791792

792793
results = append(results, private.HockProcReceiveRefResult{
793-
OldOID: old,
794-
NewOID: opts.NewCommitIDs[i],
795-
Ref: pr.GetGitRefName(),
796-
OrignRef: opts.RefFullNames[i],
794+
OldOID: old,
795+
NewOID: opts.NewCommitIDs[i],
796+
Ref: pr.GetGitRefName(),
797+
OrignRef: opts.RefFullNames[i],
798+
IsForcePush: isForcePush,
797799
})
798800
}
799801

0 commit comments

Comments
 (0)