diff options
author | a1012112796 <1012112796@qq.com> | 2021-10-09 01:03:04 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-08 19:03:04 +0200 |
commit | bb393596689ee7c33ecb041806ae2c9e8dc5dfab (patch) | |
tree | c6b71f73e53d5d5c1bb1da9e47e917f23538cd3f /modules/git | |
parent | 56d79301b9f212e7801cbced1475238cc61c0748 (diff) | |
download | gitea-bb393596689ee7c33ecb041806ae2c9e8dc5dfab.tar.gz gitea-bb393596689ee7c33ecb041806ae2c9e8dc5dfab.zip |
Add a simple way to rename branch like gh (#15870)
- Update default branch if needed
- Update protected branch if needed
- Update all not merged pull request base branch name
- Rename git branch
- Record this rename work and auto redirect for old branch on ui
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'modules/git')
-rw-r--r-- | modules/git/repo_branch.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go index 7c30b1fb20..96f692826e 100644 --- a/modules/git/repo_branch.go +++ b/modules/git/repo_branch.go @@ -164,3 +164,9 @@ func (repo *Repository) RemoveRemote(name string) error { func (branch *Branch) GetCommit() (*Commit, error) { return branch.gitRepo.GetBranchCommit(branch.Name) } + +// RenameBranch rename a branch +func (repo *Repository) RenameBranch(from, to string) error { + _, err := NewCommand("branch", "-m", from, to).RunInDir(repo.Path) + return err +} |