mirror of
https://github.com/go-gitea/gitea.git
synced 2024-11-04 08:17:24 -05:00
Set default branchname on first push (#3715)
This commit is contained in:
parent
cb87f29b76
commit
321cc2a3d0
@ -523,6 +523,11 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
return fmt.Errorf("GetRepositoryByName [owner_id: %d, name: %s]: %v", opts.RepoOwnerID, opts.RepoName, err)
|
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.
|
// Change repository bare status and update last updated time.
|
||||||
repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
|
repo.IsBare = repo.IsBare && opts.Commits.Len <= 0
|
||||||
if err = UpdateRepository(repo, false); err != nil {
|
if err = UpdateRepository(repo, false); err != nil {
|
||||||
@ -563,7 +568,6 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
|||||||
return fmt.Errorf("Marshal: %v", err)
|
return fmt.Errorf("Marshal: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
refName := git.RefEndName(opts.RefFullName)
|
|
||||||
if err = NotifyWatchers(&Action{
|
if err = NotifyWatchers(&Action{
|
||||||
ActUserID: pusher.ID,
|
ActUserID: pusher.ID,
|
||||||
ActUser: pusher,
|
ActUser: pusher,
|
||||||
|
Loading…
Reference in New Issue
Block a user