diff options
author | Unknwon <u@gogs.io> | 2015-11-18 19:32:23 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-18 19:32:23 -0500 |
commit | 2c653141a83eb5bc3fb1baaff0449195b9e1f6a6 (patch) | |
tree | 4aab191a53427da0c17a58d42ef01e2f1b28c550 /modules/git/repo_branch.go | |
parent | f04d773f4f72f8f167b7ceed4d4e9a6fd4e6ad16 (diff) | |
download | gitea-2c653141a83eb5bc3fb1baaff0449195b9e1f6a6.tar.gz gitea-2c653141a83eb5bc3fb1baaff0449195b9e1f6a6.zip |
#1742 Update default branch in git repository while change in web view
Diffstat (limited to 'modules/git/repo_branch.go')
-rw-r--r-- | modules/git/repo_branch.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go index a4e060533c..86c4f538b4 100644 --- a/modules/git/repo_branch.go +++ b/modules/git/repo_branch.go @@ -35,3 +35,16 @@ func (repo *Repository) GetBranches() ([]string, error) { } return branches, nil } + +// SetDefaultBranch sets default branch of repository. +func (repo *Repository) SetDefaultBranch(branchName string) error { + if gitVer.LessThan(MustParseVersion("1.7.10")) { + return ErrUnsupportedVersion{"1.7.10"} + } + + _, stderr, err := com.ExecCmdDir(repo.Path, "git", "symbolic-ref", "HEAD", "refs/heads/"+branchName) + if err != nil { + return concatenateError(err, stderr) + } + return nil +} |