diff options
author | Meaglith Ma <genedna@gmail.com> | 2014-03-31 17:23:37 +0800 |
---|---|---|
committer | Meaglith Ma <genedna@gmail.com> | 2014-03-31 17:23:37 +0800 |
commit | 1a247340dbea3404431f60a24bb8f8d06d94b1e9 (patch) | |
tree | 80d3ecab43506e03405c742a84dcc61f474e2212 /models/git.go | |
parent | 9047cadcd33f95eebafa2f794b895c8406eb80c5 (diff) | |
parent | dd9fb807a46db120ef800d7465f50a73a86df288 (diff) |
Merge pull request #1 from gogits/master
Sync to lastest
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 } |