Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global default branch setting #11918

Merged
merged 6 commits into from
Jun 17, 2020

Conversation

techknowlogick
Copy link
Member

as title

@techknowlogick techknowlogick added type/enhancement An improvement of existing functionality backport/v1.12 labels Jun 16, 2020
@techknowlogick techknowlogick added this to the 1.13.0 milestone Jun 16, 2020
@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jun 16, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jun 16, 2020
@6543
Copy link
Member

6543 commented Jun 16, 2020

🚀

Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sadly it is not that easy

@6543
Copy link
Member

6543 commented Jun 16, 2020

if refFullNames[count] == git.BranchPrefix+"master" && newCommitIDs[count] != git.EmptySHA && count == total {

@6543
Copy link
Member

6543 commented Jun 16, 2020

gitea/cmd/hook.go

Lines 380 to 381 in 262fce6

// We need to tell the repo to reset the default branch to master
err := private.SetDefaultBranch(repoUser, repoName, "master")

@6543
Copy link
Member

6543 commented Jun 16, 2020

gitea/cmd/hook.go

Lines 411 to 412 in 262fce6

// We need to tell the repo to reset the default branch to master
err := private.SetDefaultBranch(repoUser, repoName, "master")

@6543
Copy link
Member

6543 commented Jun 16, 2020

git push -u origin {{if ne .Repository.DefaultBranch "master"}}master:{{.Repository.DefaultBranch}}{{else}}master{{end}}</code></pre>

@6543
Copy link
Member

6543 commented Jun 16, 2020

if repo.IsEmpty && option.IsBranch() && option.BranchName() == "master" {
// put the master branch first

@CirnoT
Copy link
Contributor

CirnoT commented Jun 16, 2020

These issues existed before too if user changed their default branch, nice catch.

@CirnoT
Copy link
Contributor

CirnoT commented Jun 16, 2020

Actually, this looks like it was intentionally there so that even if repo is created with other branch as default, and then master is pushed, it would reset repo to that branch.

I am not sure this is desired at all, either with master or with any other name.

@silverwind
Copy link
Member

Needs entry in custom/conf/app.ini.sample

@techknowlogick
Copy link
Member Author

techknowlogick commented Jun 16, 2020

gitea/templates/repo/empty.tmpl

@6543 this one has to be kept this way as git init defaults the branch name and doesn't have configuration options to change it.

@techknowlogick
Copy link
Member Author

@silverwind updated.

@lunny
Copy link
Member

lunny commented Jun 17, 2020

@techknowlogick We can add an extra git command fmt.Sprintf("git branch -m master %s", settings.DefaultBranch) to change the default branch name.

ref. https://www.hanselman.com/blog/EasilyRenameYourGitDefaultBranchFromMasterToMain.aspx

lunny
lunny previously requested changes Jun 17, 2020
Copy link
Member

@lunny lunny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

per my comment

@techknowlogick
Copy link
Member Author

@lunny updated

@techknowlogick techknowlogick merged commit 6bf78d2 into go-gitea:master Jun 17, 2020
@techknowlogick techknowlogick deleted the default-branch-option branch June 17, 2020 20:54
techknowlogick added a commit to techknowlogick/gitea that referenced this pull request Jun 17, 2020
* Global default branch setting

* add to app.ini example per @silverwind

* update per @lunny

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
@techknowlogick techknowlogick added the backport/done All backports for this PR have been created label Jun 17, 2020
techknowlogick added a commit that referenced this pull request Jun 17, 2020
* Global default branch setting (#11918)

* Global default branch setting

* add to app.ini example per @silverwind

* update per @lunny

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

* Update modules/setting/repository.go

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
* Global default branch setting

* add to app.ini example per @silverwind

* update per @lunny

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants