aboutsummaryrefslogtreecommitdiffstats
path: root/modules/git/repo_branch.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/git/repo_branch.go')
-rw-r--r--modules/git/repo_branch.go67
1 files changed, 0 insertions, 67 deletions
diff --git a/modules/git/repo_branch.go b/modules/git/repo_branch.go
index 916391f167..e7ecf53f51 100644
--- a/modules/git/repo_branch.go
+++ b/modules/git/repo_branch.go
@@ -7,7 +7,6 @@ package git
import (
"context"
"errors"
- "fmt"
"strings"
)
@@ -25,36 +24,6 @@ func IsBranchExist(ctx context.Context, repoPath, name string) bool {
return IsReferenceExist(ctx, repoPath, BranchPrefix+name)
}
-// Branch represents a Git branch.
-type Branch struct {
- Name string
- Path string
-
- gitRepo *Repository
-}
-
-// GetHEADBranch returns corresponding branch of HEAD.
-func (repo *Repository) GetHEADBranch() (*Branch, error) {
- if repo == nil {
- return nil, fmt.Errorf("nil repo")
- }
- stdout, _, err := NewCommand("symbolic-ref", "HEAD").RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})
- if err != nil {
- return nil, err
- }
- stdout = strings.TrimSpace(stdout)
-
- if !strings.HasPrefix(stdout, BranchPrefix) {
- return nil, fmt.Errorf("invalid HEAD branch: %v", stdout)
- }
-
- return &Branch{
- Name: stdout[len(BranchPrefix):],
- Path: stdout,
- gitRepo: repo,
- }, nil
-}
-
func GetDefaultBranch(ctx context.Context, repoPath string) (string, error) {
stdout, _, err := NewCommand("symbolic-ref", "HEAD").RunStdString(ctx, &RunOpts{Dir: repoPath})
if err != nil {
@@ -67,37 +36,6 @@ func GetDefaultBranch(ctx context.Context, repoPath string) (string, error) {
return strings.TrimPrefix(stdout, BranchPrefix), nil
}
-// GetBranch returns a branch by it's name
-func (repo *Repository) GetBranch(branch string) (*Branch, error) {
- if !repo.IsBranchExist(branch) {
- return nil, ErrBranchNotExist{branch}
- }
- return &Branch{
- Path: repo.Path,
- Name: branch,
- gitRepo: repo,
- }, nil
-}
-
-// GetBranches returns a slice of *git.Branch
-func (repo *Repository) GetBranches(skip, limit int) ([]*Branch, int, error) {
- brs, countAll, err := repo.GetBranchNames(skip, limit)
- if err != nil {
- return nil, 0, err
- }
-
- branches := make([]*Branch, len(brs))
- for i := range brs {
- branches[i] = &Branch{
- Path: repo.Path,
- Name: brs[i],
- gitRepo: repo,
- }
- }
-
- return branches, countAll, nil
-}
-
// DeleteBranchOptions Option(s) for delete branch
type DeleteBranchOptions struct {
Force bool
@@ -147,11 +85,6 @@ func (repo *Repository) RemoveRemote(name string) error {
return err
}
-// GetCommit returns the head commit of a branch
-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").AddDynamicArguments(from, to).RunStdString(repo.Ctx, &RunOpts{Dir: repo.Path})