]> source.dussan.org Git - gitea.git/commitdiff
Push update after branch is restored (#9416)
authorMario Lubenka <mario.lubenka@googlemail.com>
Thu, 26 Dec 2019 13:17:31 +0000 (14:17 +0100)
committerLauris BH <lauris@nix.lv>
Thu, 26 Dec 2019 13:17:31 +0000 (15:17 +0200)
* Push update after branch is restored

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
* Apply suggestions from code review

Use name from deletedBranch

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
routers/repo/branch.go

index 306deca36e653a834a10e4a454051cd73bc2a7ea..b0a1efc5b92b53e482aee0f5479a40583410d35d 100644 (file)
@@ -110,6 +110,22 @@ func RestoreBranchPost(ctx *context.Context) {
                return
        }
 
+       // Don't return error below this
+       if err := repofiles.PushUpdate(
+               ctx.Repo.Repository,
+               deletedBranch.Name,
+               repofiles.PushUpdateOptions{
+                       RefFullName:  git.BranchPrefix + deletedBranch.Name,
+                       OldCommitID:  git.EmptySHA,
+                       NewCommitID:  deletedBranch.Commit,
+                       PusherID:     ctx.User.ID,
+                       PusherName:   ctx.User.Name,
+                       RepoUserName: ctx.Repo.Owner.Name,
+                       RepoName:     ctx.Repo.Repository.Name,
+               }); err != nil {
+               log.Error("Update: %v", err)
+       }
+
        ctx.Flash.Success(ctx.Tr("repo.branch.restore_success", deletedBranch.Name))
 }