diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-30 10:19:36 +0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2014-03-30 10:19:36 +0800 |
commit | cd800d7837caefb129e0f006c8973460a2d64d4a (patch) | |
tree | 6c5f06fd3a1802c07332f247e2a1b3d2bc0b5c1b /models/git.go | |
parent | 50391f434e9f7f216ce0f907b532cbe4ca2bbeb2 (diff) | |
parent | b27c34f39acee3bf7b6594a1f0db2183b343326c (diff) |
Merge branch 'master' of github.com:gogits/gogs
Diffstat (limited to 'models/git.go')
-rw-r--r-- | models/git.go | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/models/git.go b/models/git.go index 34f0267f..d3bad6e0 100644 --- a/models/git.go +++ b/models/git.go @@ -70,9 +70,12 @@ func GetTargetFile(userName, repoName, branchName, commitId, rpath string) (*Rep return nil, err } - commit, err := repo.GetCommit(branchName, commitId) + commit, err := repo.GetCommitOfBranch(branchName) if err != nil { - return nil, err + commit, err = repo.GetCommit(commitId) + if err != nil { + return nil, err + } } parts := strings.Split(path.Clean(rpath), "/") @@ -110,13 +113,22 @@ func GetTargetFile(userName, repoName, branchName, commitId, rpath string) (*Rep } // GetReposFiles returns a list of file object in given directory of repository. -func GetReposFiles(userName, repoName, branchName, commitId, rpath string) ([]*RepoFile, error) { +// func GetReposFilesOfBranch(userName, repoName, branchName, rpath string) ([]*RepoFile, error) { +// return getReposFiles(userName, repoName, commitId, rpath) +// } + +// GetReposFiles returns a list of file object in given directory of repository. +func GetReposFiles(userName, repoName, commitId, rpath string) ([]*RepoFile, error) { + return getReposFiles(userName, repoName, commitId, rpath) +} + +func getReposFiles(userName, repoName, commitId string, rpath string) ([]*RepoFile, error) { repo, err := git.OpenRepository(RepoPath(userName, repoName)) if err != nil { return nil, err } - commit, err := repo.GetCommit(branchName, commitId) + commit, err := repo.GetCommit(commitId) if err != nil { return nil, err } @@ -216,13 +228,13 @@ func GetReposFiles(userName, repoName, branchName, commitId, rpath string) ([]*R return append(repodirs, repofiles...), nil } -func GetCommit(userName, repoName, branchname, commitid string) (*git.Commit, error) { +func GetCommit(userName, repoName, commitId string) (*git.Commit, error) { repo, err := git.OpenRepository(RepoPath(userName, repoName)) if err != nil { return nil, err } - return repo.GetCommit(branchname, commitid) + return repo.GetCommit(commitId) } // GetCommitsByBranch returns all commits of given branch of repository. @@ -397,7 +409,7 @@ func GetDiff(repoPath, commitid string) (*Diff, error) { return nil, err } - commit, err := repo.GetCommit("", commitid) + commit, err := repo.GetCommit(commitid) if err != nil { return nil, err } |