summaryrefslogtreecommitdiffstats
path: root/models/action.go
diff options
context:
space:
mode:
authorBwko <bouwko@gmail.com>2018-03-25 15:00:07 +0200
committerLunny Xiao <xiaolunwen@gmail.com>2018-03-25 21:00:07 +0800
commit321cc2a3d0f267f8b0f5bb4365572636f1ce0443 (patch)
tree8c80e492f7b17d9a9231cdd805a38dbe63232fc8 /models/action.go
parentcb87f29b76f661d9c726579067c9c64db55fd970 (diff)
downloadgitea-321cc2a3d0f267f8b0f5bb4365572636f1ce0443.tar.gz
gitea-321cc2a3d0f267f8b0f5bb4365572636f1ce0443.zip
Set default branchname on first push (#3715)
Diffstat (limited to 'models/action.go')
-rw-r--r--models/action.go6
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,