Skip to content

Commit

Permalink
feat(BitbucketPullRequests): commits of a pull request (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
knowbased authored Feb 6, 2025
1 parent f8b3d09 commit 2f17686
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/BitbucketPharoAPI-Tests/BitbucketPullRequestsTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,45 @@ BitbucketPullRequestsTest >> testActivitiesOfInRepositoryOfProject [
self assert: result equals: pullRequestActivity
]

{ #category : 'tests' }
BitbucketPullRequestsTest >> testCommitsOfInRepositoryOfProject [

| hostUrl gitlabApi result client path bitbucketPullRequests pullRequestID projectKey repoSlug commit |
"Given"
hostUrl := 'www.url.com'.
client := ZnClient new.

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

bitbucketPullRequests := BitbucketPullRequests new bitbucketApi:
gitlabApi.

pullRequestID := 24.
projectKey := 'AAA'.
repoSlug := 'project'.

commit := { (#commitId -> 'id') }
asDictionary.

path := '/projects/' , projectKey , '/repos/' , repoSlug
, '/pull-requests/' , pullRequestID asString , '/commits'.

(bitbucketPullRequests stub getAll: path withParams: Dictionary new)
willReturn: commit.

"When"
result := bitbucketPullRequests
commitsOf: pullRequestID
inRepository: repoSlug
ofProject: projectKey.

"Then"
self assert: result equals: commit
]

{ #category : 'tests' }
BitbucketPullRequestsTest >> testCreateFromRefToRefInRepositoryOfProject [

Expand Down
10 changes: 10 additions & 0 deletions src/BitbucketPharoAPI/BitbucketPullRequests.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ BitbucketPullRequests >> activitiesOf: pullRequestId inRepository: repositorySlu
^ self getAll: endpoint withParams: Dictionary new.
]

{ #category : 'api - get' }
BitbucketPullRequests >> commitsOf: pullRequestId inRepository: repositorySlug ofProject: projectKey [
"GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/commits"

| endpoint |
endpoint := '/projects/', projectKey, '/repos/', repositorySlug, '/pull-requests/', pullRequestId asString, '/commits'.

^self getAll: endpoint withParams: Dictionary new.
]

{ #category : 'api - post' }
BitbucketPullRequests >> create: title fromRef: fromRefId toRef: toRefId inRepository: repositorySlug ofProject: projectKey [
"POST /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests"
Expand Down

0 comments on commit 2f17686

Please sign in to comment.