mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-26 23:35:51 +03:00
SetDefaultBranch on pushing to empty repository (#7610)
This commit is contained in:
parent
a957d4eeac
commit
4d643a59db
1 changed files with 11 additions and 0 deletions
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue