Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #95

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5b77080
put model importer inside super class
Sep 26, 2024
56314d3
Merge pull request #78 from moosetechnology/fix/model-importer
alkalinan Oct 7, 2024
22e5196
do not compute diff when server return error
badetitou Oct 7, 2024
1b1a264
Merge pull request #79 from moosetechnology/feature/error-with-bigdif…
badetitou Oct 7, 2024
947135b
enable diff range importer for Bitbucket
Oct 7, 2024
f2eb25d
add repoAPI to abstract importer; working on usercatalogue for bitbucket
Oct 8, 2024
8e34931
changing catalogue user importation for bitbucket
Oct 8, 2024
f7b43a8
Merge pull request #80 from moosetechnology/feature/commitImportBitBu…
alkalinan Oct 8, 2024
ae211a7
renaming for consistencies; fix visu case of no commits
Oct 10, 2024
5e7ee19
fix author color in commit tree visu. renaming bitbucket api method
Oct 10, 2024
6d97827
using none deprecated method
Oct 10, 2024
31cd73f
revert user: renaming; fixing on commit diff parsing
Oct 10, 2024
7276be9
fix model importer for bitbucket commit
Oct 10, 2024
eb3f2ec
deporecate repo api
badetitou Oct 11, 2024
93c7f60
Merge pull request #82 from moosetechnology/deprecate-repoapi
badetitou Oct 11, 2024
fdc3ac5
Merge pull request #81 from moosetechnology/refactoring/rename
badetitou Oct 11, 2024
85ac28a
add commit diff import for github importer
Oct 14, 2024
c6f44c1
add diff range parsing
Oct 14, 2024
74be8a8
add temp merge request importer
Oct 14, 2024
8a7e96d
fix deprecated names
Oct 15, 2024
f3f3234
fix: change userEmail to accept public_email by default
knowbased Oct 16, 2024
bb4dcf3
fix: additions are nil in commits import with importMergeRequestCommits
knowbased Oct 16, 2024
2691475
another renaming of deprecated method
Oct 16, 2024
b808647
Merge pull request #83 from moosetechnology/feature/commitdiff-github…
alkalinan Oct 16, 2024
833d56a
Merge pull request #84 from moosetechnology/fix/jira-metrics-not-work…
alkalinan Oct 16, 2024
1cf9744
feat: code addition and code deletion by merge request metric
knowbased Oct 17, 2024
b01d3f3
feat(GitMetricExporter): add code addition and deletion by mr metrics…
knowbased Oct 17, 2024
8b0a65f
add complete commit import to bitbucket methods (#86)
alkalinan Oct 17, 2024
ed0b8fb
Merge pull request #85 from moosetechnology/feat/code-contribution-by-mr
badetitou Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 40 additions & 6 deletions src/BitBucketHealth-Model-Importer-Tests/BitBucketApiMock.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,43 @@ Class {
}

{ #category : #'api - pull-requests' }
BitBucketApiMock >> activitiesOfPullRequest: pullRequestId inRepo: repoSlug ofProject: projectKey [
BitBucketApiMock >> activitiesOfPullRequest: pullRequestId inRepoProjectId: repoSlug ofProjectGroupId: projectKey [

^self pullRequestActivities
]

{ #category : #accessing }
BitBucketApiMock >> commit2 [

| commits2 |
commits2 := '
{
"id": "abcdef0123abcdef4567abcdef8987abcdef6543",
"message": "message test",
"displayId": "abcdef0123a",
"author": {
"name": "charlie",
"emailAddress": "[email protected]"
},
"authorTimestamp": 1727168151000,
"committer": {
"name": "charlie",
"emailAddress": "[email protected]"
},
"committerTimestamp": 1727168151000,
"message": "WIP on feature 1",
"parents": [
{
"id": "abcdef0123abcdef4567abcdef8987abcdef6543",
"displayId": "abcdef0"
}
]
}
'.

^ commits2 := (NeoJSONReader on: commits2 readStream) next
]

{ #category : #accessing }
BitBucketApiMock >> commits [

Expand Down Expand Up @@ -61,18 +93,20 @@ BitBucketApiMock >> commits: anObject [
]

{ #category : #'api - pull-requests' }
BitBucketApiMock >> commitsOfPullRequest: mergeRequestId ofRepo: repoSlug inProject: projectKey [
BitBucketApiMock >> commitsOfPullRequest: mergeRequestId ofRepoProjectId: repoSlug inProjectGroupId: projectKey [

^commits
]

{ #category : #'api - projects' }
BitBucketApiMock >> commitsOfRepo: repositorySlug inProject: projectKey since: since until: until [
BitBucketApiMock >> commitsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [

^ self commits select: [ :commit |
| commitDate |

commitDate := DateAndTime fromUnixTime:
(commit at: #committerTimestamp) / 1000.

commitDate >= since asDate and: commitDate <= until asDate ]
]

Expand Down Expand Up @@ -382,7 +416,7 @@ BitBucketApiMock >> diffs: anObject [
]

{ #category : #'api - commits' }
BitBucketApiMock >> diffsOfCommit: commitID inRepo: repositorySlug inProject: projectKey [
BitBucketApiMock >> diffsOfCommit: commitID inRepoProjectId: repositorySlug inProjectGroupId: projectKey [
^diffs
]

Expand Down Expand Up @@ -1078,13 +1112,13 @@ BitBucketApiMock >> pullRequestActivities [
]

{ #category : #'api - pull-requests' }
BitBucketApiMock >> pullRequestsOfRepo: repoSlug inProject: projectKey since: since until: until [
BitBucketApiMock >> pullRequestsOfRepoProjectId: repoSlug inProjectGroupId: projectKey since: since until: until [

^ mergeRequests
]

{ #category : #'api - projects' }
BitBucketApiMock >> repositoriesOfProject: projectKey [
BitBucketApiMock >> repositoryProjectsOfProjectGroupId: projectKey [

| repos |
repos := '[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,58 @@ BitBucketModelImporterTest >> testGetContributionFromDiffsWithoutRemoved [
self assert: (contribution at: #deletions) equals: 0
]

{ #category : #tests }
BitBucketModelImporterTest >> testImportAndLoadLatestsCommitsOfProject [

| bitBucketApi glphModel bitBucketImporter project commits group repo firstCommit commit1 currentDate timestamp commit2 timestamp2 |
"Given"
bitBucketApi := BitBucketApiMock new.

glphModel := GLPHEModel new name: 'test'.

bitBucketImporter := BitBucketModelImporter new
bitBucketApi: bitBucketApi;
glhModel: glphModel;
withCommitDiffs: true.

group := GLHGroup new id: 1.
repo := GLHRepository new.
project := GLHProject new
group: group;
repository: repo.

commit1 := bitBucketApi commits1 first.
currentDate := DateAndTime today.
timestamp := (currentDate - 1 weeks) asUnixTime * 1000.
commit1 at: 'committerTimestamp' put: timestamp.

commit2 := bitBucketApi commit2.
timestamp2 := (currentDate - 4 weeks) asUnixTime * 1000.
commit2 at: 'committerTimestamp' put: timestamp2.


bitBucketApi commits: {
commit1.
commit2 }.

"When"
commits := bitBucketImporter importAndLoadLatestsCommitsOfProject:
project.

"Then"
self
assert: (bitBucketImporter glhModel allWithType: GLHCommit) size
equals: 1.

self assert: project repository commits size equals: 1.
firstCommit := project repository commits first.
self assert: firstCommit additions equals: 1
]

{ #category : #tests }
BitBucketModelImporterTest >> testImportCommitsOfProjectSinceUntil [

| bitBucketApi glphModel bitBucketImporter project commits group repo |
| bitBucketApi glphModel bitBucketImporter project commits group repo firstCommit |
"Given"
bitBucketApi := BitBucketApiMock new.

Expand All @@ -160,8 +208,10 @@ BitBucketModelImporterTest >> testImportCommitsOfProjectSinceUntil [
self
assert: (bitBucketImporter glhModel allWithType: GLHCommit) size
equals: 1.

self assert: project repository commits size equals: 1.

self assert: project repository commits size equals: 1.
firstCommit := project repository commits first.
self assert: firstCommit additions equals: 1
]

{ #category : #tests }
Expand Down Expand Up @@ -282,7 +332,8 @@ BitBucketModelImporterTest >> testImportMergeRequestCommits [

"Then"
self deny: mergeRequest commits equals: nil.
self assert: mergeRequest commits equals: commits
self assert: mergeRequest commits equals: commits.
self assert: mergeRequest commits first additions equals: 1
]

{ #category : #tests }
Expand Down
14 changes: 7 additions & 7 deletions src/BitBucketHealth-Model-Importer/BitBucketApi.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Class {
}

{ #category : #'api - pull-requests' }
BitBucketApi >> activitiesOfPullRequest: pullRequestId inRepo: repositorySlug ofProject: projectKey [
BitBucketApi >> activitiesOfPullRequest: pullRequestId inRepoProjectId: repositorySlug ofProjectGroupId: projectKey [

^ self allValuesOfPath:
self basePath , '/projects/' , projectKey , '/repos/'
Expand Down Expand Up @@ -91,21 +91,21 @@ BitBucketApi >> client: anObject [
]

{ #category : #'api - pull-requests' }
BitBucketApi >> commitsOfPullRequest: pullRequestId ofRepo: repoSlug inProject: projectKey [
BitBucketApi >> commitsOfPullRequest: pullRequestId ofRepoProjectId: repoSlug inProjectGroupId: projectKey [
^ self allValuesOfPath: self basePath, '/projects/', projectKey, '/repos/', repoSlug, '/pull-requests/', pullRequestId printString, '/commits'.

]

{ #category : #'api - commits' }
BitBucketApi >> commitsOfRepo: repositorySlug inProject: projectKey since: since until: until [
BitBucketApi >> commitsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [
"/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits"

| results lastDate lastCommitterTimestamp commits |
self prepareZnClient.
self client path:
self basePath , '/projects/' , projectKey , '/repos/'
, repositorySlug , '/commits'.
self client queryAt: 'merges' put: 'exclude'.
"self client queryAt: 'merges' put: 'exclude'."

commits := OrderedCollection new.

Expand Down Expand Up @@ -134,7 +134,7 @@ BitBucketApi >> commitsOfRepo: repositorySlug inProject: projectKey since: since
]

{ #category : #'api - commits' }
BitBucketApi >> diffsOfCommit: commitID inRepo: repositorySlug inProject: projectKey [
BitBucketApi >> diffsOfCommit: commitID inRepoProjectId: repositorySlug inProjectGroupId: projectKey [

| results |
self prepareZnClient.
Expand Down Expand Up @@ -195,7 +195,7 @@ BitBucketApi >> projects [
]

{ #category : #'api - pull-requests' }
BitBucketApi >> pullRequestsOfRepo: repositorySlug inProject: projectKey since: since until: until [
BitBucketApi >> pullRequestsOfRepoProjectId: repositorySlug inProjectGroupId: projectKey since: since until: until [

| pullRequests results lastCommitterTimestamp lastDate |
self prepareZnClient.
Expand Down Expand Up @@ -231,7 +231,7 @@ BitBucketApi >> pullRequestsOfRepo: repositorySlug inProject: projectKey since:
]

{ #category : #'api - projects' }
BitBucketApi >> repositoriesOfProject: projectKey [
BitBucketApi >> repositoryProjectsOfProjectGroupId: projectKey [
^self allValuesOfPath: self basePath, '/projects/', projectKey, '/repos'.
]

Expand Down
Loading
Loading