Skip to content

Commit

Permalink
feat(BitbucketCommits): diffs of a commit (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
knowbased authored Feb 5, 2025
1 parent a25fc08 commit 61e400c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/BitbucketPharoAPI-Tests/BitbucketCommitsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,37 @@ BitbucketCommitsTest >> testAllWithParamsInRepositoryOfProject [
"Then"
self assert: result equals: response
]

{ #category : 'tests' }
BitbucketCommitsTest >> testDiffOfInRepositoryOfProject [

| hostUrl client bitbucketApi projectKey repositorySlug endpoint response result bitbucketCommits commitId |
"Given"
hostUrl := 'www.url.com'.
client := Mock new.

bitbucketApi := BitbucketApi new
bearerToken: 'token';
host: hostUrl;
client: client.

bitbucketCommits := BitbucketCommits new bitbucketApi: bitbucketApi.

projectKey := 'OOO'.
repositorySlug := 'my project'.
commitId := 'aaezf1'.

endpoint := '/projects/' , projectKey , '/repos/' , repositorySlug
, '/commits/' , commitId , '/diff'.

response := { (#diff -> '1') } asDictionary.

(bitbucketCommits stub get: endpoint withParams: Dictionary new)
willReturn: response.

"When"
result := bitbucketCommits diffOf: commitId inRepository: repositorySlug ofProject: projectKey.

"Then"
self assert: result equals: response
]
11 changes: 11 additions & 0 deletions src/BitbucketPharoAPI/BitbucketCommits.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ BitbucketCommits >> allWithParams: paramsDictionary inRepository: repositorySlug
endpoint := '/projects/', projectKey, '/repos/', repositorySlug, '/commits'.
^self getAll: endpoint withParams: paramsDictionary.
]

{ #category : 'api - get' }
BitbucketCommits >> diffOf: commitId inRepository: repositorySlug ofProject: projectKey [
"GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/diff?autoSrcPath&contextLines&since&srcPath&whitespace&withComments"

| endpoint |
endpoint := '/projects/' , projectKey , '/repos/' , repositorySlug
, '/commits/' , commitId , '/diff'.

^ self get: endpoint withParams: Dictionary new
]

0 comments on commit 61e400c

Please sign in to comment.