diff options
author | zeripath <art27@cantab.net> | 2019-07-30 02:05:33 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2019-07-30 09:05:33 +0800 |
commit | 4d643a59db49ae47870326abb5fed8562e1d71a5 (patch) | |
tree | 88377b641ae68c9cac55a6d9fbe1ffd83255c8f1 /models | |
parent | a957d4eeac4142e232896c22b45e63de6f21520f (diff) | |
download | gitea-4d643a59db49ae47870326abb5fed8562e1d71a5.tar.gz gitea-4d643a59db49ae47870326abb5fed8562e1d71a5.zip |
SetDefaultBranch on pushing to empty repository (#7610)
Diffstat (limited to 'models')
-rw-r--r-- | models/action.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/models/action.go b/models/action.go index c819c286e2..0253e2add0 100644 --- a/models/action.go +++ b/models/action.go @@ -685,6 +685,17 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { if repo.IsEmpty && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) { repo.DefaultBranch = refName repo.IsEmpty = false + if refName != "master" { + gitRepo, err := git.OpenRepository(repo.RepoPath()) + if err != nil { + return err + } + if err := gitRepo.SetDefaultBranch(repo.DefaultBranch); err != nil { + if !git.IsErrUnsupportedVersion(err) { + return err + } + } + } } // Change repository empty status and update last updated time. |