mirror of
https://github.com/go-gitea/gitea
synced 2024-06-08 14:18:11 +02:00
Add some comments for post receive
This commit is contained in:
parent
6c44844222
commit
ff65f3cb50
|
@ -41,6 +41,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
updates := make([]*repo_module.PushUpdateOptions, 0, len(opts.OldCommitIDs))
|
updates := make([]*repo_module.PushUpdateOptions, 0, len(opts.OldCommitIDs))
|
||||||
wasEmpty := false
|
wasEmpty := false
|
||||||
|
|
||||||
|
// generate updates and put the master/main branch first
|
||||||
for i := range opts.OldCommitIDs {
|
for i := range opts.OldCommitIDs {
|
||||||
refFullName := opts.RefFullNames[i]
|
refFullName := opts.RefFullNames[i]
|
||||||
|
|
||||||
|
@ -80,12 +81,22 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// sync branches to the database, if failed return error to keep branches consistent between disk and database
|
||||||
if repo != nil && len(updates) > 0 {
|
if repo != nil && len(updates) > 0 {
|
||||||
syncBranches(ctx, updates, repo, opts.UserID)
|
syncBranches(ctx, updates, repo, opts.UserID)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle possible Push Options
|
||||||
|
handlePushOptions(ctx, opts, repo, ownerName, repoName)
|
||||||
|
if ctx.Written() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// push updates to a queue so some notificactions can be handled async
|
||||||
|
if len(updates) > 0 {
|
||||||
if err := repo_service.PushUpdates(updates); err != nil {
|
if err := repo_service.PushUpdates(updates); err != nil {
|
||||||
log.Error("Failed to Update: %s/%s Total Updates: %d, Error: %v", ownerName, repoName, len(updates), err)
|
log.Error("Failed to Update: %s/%s Total Updates: %d, Error: %v", ownerName, repoName, len(updates), err)
|
||||||
for i, update := range updates {
|
for i, update := range updates {
|
||||||
|
@ -99,11 +110,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePushOptions(ctx, opts, repo, ownerName, repoName)
|
// generate branch results for end user. i.e. Displaying a link to create a PR
|
||||||
if ctx.Written() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
results := generateBranchResults(ctx, opts, repo, ownerName, repoName, wasEmpty)
|
results := generateBranchResults(ctx, opts, repo, ownerName, repoName, wasEmpty)
|
||||||
if ctx.Written() {
|
if ctx.Written() {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user