|
|
|
@ -35,6 +35,15 @@ func (s *gitService) FindBranch(ctx context.Context, repo, name string) (*scm.Re
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *gitService) FindCommit(ctx context.Context, repo, ref string) (*scm.Commit, *scm.Response, error) {
|
|
|
|
|
// github and gitlab permit fetching a commit by sha
|
|
|
|
|
// or branch. This code emulates the github and gitlab
|
|
|
|
|
// behavior for bitbucket by fetching the commit sha
|
|
|
|
|
// for the branch and using in the subsequent API call.
|
|
|
|
|
if scm.IsHash(ref) == false {
|
|
|
|
|
if branch, _, err := s.FindBranch(ctx, repo, scm.TrimRef(ref)); err == nil {
|
|
|
|
|
ref = branch.Sha // replace ref with sha
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
path := fmt.Sprintf("2.0/repositories/%s/commit/%s", repo, ref)
|
|
|
|
|
out := new(commit)
|
|
|
|
|
res, err := s.client.do(ctx, "GET", path, nil, out)
|
|
|
|
@ -217,9 +226,9 @@ func convertDiffstat(from *diffstat) *scm.Change {
|
|
|
|
|
Deleted: from.Status == "removed",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.Renamed) {
|
|
|
|
|
if response.Renamed {
|
|
|
|
|
response.PrevFilePath = from.Old.Path
|
|
|
|
|
} else if (response.Deleted) {
|
|
|
|
|
} else if response.Deleted {
|
|
|
|
|
response.Path = from.Old.Path
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|