diff options
author | Bwko <bouwko@gmail.com> | 2018-03-25 15:00:07 +0200 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-03-25 21:00:07 +0800 |
commit | 321cc2a3d0f267f8b0f5bb4365572636f1ce0443 (patch) | |
tree | 8c80e492f7b17d9a9231cdd805a38dbe63232fc8 /models/action.go | |
parent | cb87f29b76f661d9c726579067c9c64db55fd970 (diff) | |
download | gitea-321cc2a3d0f267f8b0f5bb4365572636f1ce0443.tar.gz gitea-321cc2a3d0f267f8b0f5bb4365572636f1ce0443.zip |
Set default branchname on first push (#3715)
Diffstat (limited to 'models/action.go')
-rw-r--r-- | models/action.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/models/action.go b/models/action.go index b551d79bb8..4f357cb2c5 100644 --- a/models/action.go +++ b/models/action.go @@ -523,6 +523,11 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { return fmt.Errorf("GetRepositoryByName [owner_id: %d, name: %s]: %v", opts.RepoOwnerID, opts.RepoName, err) } + refName := git.RefEndName(opts.RefFullName) + if repo.IsBare && refName != repo.DefaultBranch { + repo.DefaultBranch = refName + } + // Change repository bare status and update last updated time. repo.IsBare = repo.IsBare && opts.Commits.Len <= 0 if err = UpdateRepository(repo, false); err != nil { @@ -563,7 +568,6 @@ func CommitRepoAction(opts CommitRepoActionOptions) error { return fmt.Errorf("Marshal: %v", err) } - refName := git.RefEndName(opts.RefFullName) if err = NotifyWatchers(&Action{ ActUserID: pusher.ID, ActUser: pusher, |