aboutsummaryrefslogtreecommitdiff
path: root/modules/git/repo_branch.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-12-09 20:46:05 -0500
committerUnknwon <u@gogs.io>2015-12-09 20:46:05 -0500
commit9a2e43bff28ac92f180109fe900a6997614ea5a8 (patch)
tree564dbb6fb30c153e43b0e18499d80e7d93dd0bee /modules/git/repo_branch.go
parentbd5dc626e82e18d3e619d918e579dc130edcd1fa (diff)
move out git module and #1573 send push hook
Diffstat (limited to 'modules/git/repo_branch.go')
-rw-r--r--modules/git/repo_branch.go50
1 files changed, 0 insertions, 50 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go
deleted file mode 100644
index 86c4f538..00000000
--- a/modules/git/repo_branch.go
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2014 The Gogs Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package git
-
-import (
- "strings"
-
- "github.com/Unknwon/com"
-)
-
-func IsBranchExist(repoPath, branchName string) bool {
- _, _, err := com.ExecCmdDir(repoPath, "git", "show-ref", "--verify", "refs/heads/"+branchName)
- return err == nil
-}
-
-func (repo *Repository) IsBranchExist(branchName string) bool {
- return IsBranchExist(repo.Path, branchName)
-}
-
-func (repo *Repository) GetBranches() ([]string, error) {
- stdout, stderr, err := com.ExecCmdDir(repo.Path, "git", "show-ref", "--heads")
- if err != nil {
- return nil, concatenateError(err, stderr)
- }
- infos := strings.Split(stdout, "\n")
- branches := make([]string, len(infos)-1)
- for i, info := range infos[:len(infos)-1] {
- parts := strings.Split(info, " ")
- if len(parts) != 2 {
- continue // NOTE: I should believe git will not give me wrong string.
- }
- branches[i] = strings.TrimPrefix(parts[1], "refs/heads/")
- }
- 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
-}