aboutsummaryrefslogtreecommitdiffstats
path: root/models/repo_branch.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-02-02 17:07:40 -0500
committerUnknwon <u@gogs.io>2016-02-02 17:07:40 -0500
commit995487e82259d9a5e912d57f00dda68db8607d49 (patch)
tree3c937dd5c1fa0a364b7a348f8d9ca70f7936237d /models/repo_branch.go
parent5e97693e0e44037bdf60c6399f957102fed7c93c (diff)
downloadgitea-995487e82259d9a5e912d57f00dda68db8607d49.tar.gz
gitea-995487e82259d9a5e912d57f00dda68db8607d49.zip
Minor fix for #2506
Diffstat (limited to 'models/repo_branch.go')
-rw-r--r--models/repo_branch.go24
1 files changed, 19 insertions, 5 deletions
diff --git a/models/repo_branch.go b/models/repo_branch.go
index b784f7d537..9cf2e9c43e 100644
--- a/models/repo_branch.go
+++ b/models/repo_branch.go
@@ -9,8 +9,8 @@ import (
)
type Branch struct {
- Path string
- Name string
+ Path string
+ Name string
}
func GetBranchesByPath(path string) ([]*Branch, error) {
@@ -24,14 +24,28 @@ func GetBranchesByPath(path string) ([]*Branch, error) {
return nil, err
}
- Branches := make([]*Branch, len(brs))
+ branches := make([]*Branch, len(brs))
for i := range brs {
- Branches[i] = &Branch{
+ branches[i] = &Branch{
Path: path,
Name: brs[i],
}
}
- return Branches, nil
+ return branches, nil
+}
+
+func (repo *Repository) GetBranch(br string) (*Branch, error) {
+ if !git.IsBranchExist(repo.RepoPath(), br) {
+ return nil, &ErrBranchNotExist{br}
+ }
+ return &Branch{
+ Path: repo.RepoPath(),
+ Name: br,
+ }, nil
+}
+
+func (repo *Repository) GetBranches() ([]*Branch, error) {
+ return GetBranchesByPath(repo.RepoPath())
}
func (br *Branch) GetCommit() (*git.Commit, error) {