summaryrefslogtreecommitdiffstats
path: root/modules/git
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-10-09 01:03:04 +0800
committerGitHub <noreply@github.com>2021-10-08 19:03:04 +0200
commitbb393596689ee7c33ecb041806ae2c9e8dc5dfab (patch)
treec6b71f73e53d5d5c1bb1da9e47e917f23538cd3f /modules/git
parent56d79301b9f212e7801cbced1475238cc61c0748 (diff)
downloadgitea-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.go6
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
+}