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

add import for only one project #68

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 8 additions & 1 deletion src/GitHubHealth-Model-Importer/GHApi.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Class {
'baseAPIUrl',
'client'
],
#category : 'GitHubHealth-Model-Importer'
#category : #'GitHubHealth-Model-Importer'
}

{ #category : #api }
Expand Down Expand Up @@ -101,6 +101,13 @@ GHApi >> organization: anOrganizationName [
^ self client get: self baseAPIUrl , '/orgs/' , anOrganizationName
]

{ #category : #api }
GHApi >> organization: aGroupName repo: aRepoName [

^ self client get:
self baseAPIUrl , '/repos/' , aGroupName , '/' , aRepoName
]

{ #category : #accessing }
GHApi >> privateToken [

Expand Down
49 changes: 43 additions & 6 deletions src/GitHubHealth-Model-Importer/GHModelImporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Class {
#instVars : [
'api'
],
#category : 'GitHubHealth-Model-Importer'
#category : #'GitHubHealth-Model-Importer'
}

{ #category : #accessing }
Expand Down Expand Up @@ -42,6 +42,15 @@ GHModelImporter >> convertApiFileAsFile: aAPIFile [
yourself
]

{ #category : #api }
GHModelImporter >> ensureGroupNamed: aGroupName [

^ self glhModel
detect: [ :a |
(a isKindOf: GLHGroup) and: [ a name = aGroupName ] ]
ifNone: [ self glhModel newGroupNamed: aGroupName ]
]

{ #category : #api }
GHModelImporter >> importBranchesOf: project [

Expand Down Expand Up @@ -173,6 +182,19 @@ GHModelImporter >> importPipelinesOf: project [
project addPipeline: pipeline ]
]

{ #category : #api }
GHModelImporter >> importProject: aProjectName ofGroup: aGroupName [

| result projectResult group |
group := self ensureGroupNamed: aGroupName.
result := self api organization: aGroupName repo: aProjectName.
projectResult := self parseProjectResult: result.
projectResult group: group.
self glhModel add: projectResult.
self completeImportProject: projectResult.
^ projectResult
]

{ #category : #api }
GHModelImporter >> importRepositoriesOfGroup: groupResult [

Expand Down Expand Up @@ -230,7 +252,7 @@ GHModelImporter >> initialize [
withFiles := false
]

{ #category : #private }
{ #category : #parsing }
GHModelImporter >> parseArrayOfProject: arrayOfProjects [

| reader |
Expand All @@ -249,7 +271,7 @@ GHModelImporter >> parseArrayOfProject: arrayOfProjects [
^ reader nextAs: #ArrayOfProjects
]

{ #category : #private }
{ #category : #parsing }
GHModelImporter >> parseBranchesResult: arrayOfBranch [

| reader |
Expand Down Expand Up @@ -318,7 +340,7 @@ GHModelImporter >> parseCommitsResult: result [
^ reader nextAs: #ArrayOfCommit
]

{ #category : #private }
{ #category : #parsing }
GHModelImporter >> parseFileTreeResult: aResult [

| reader |
Expand All @@ -331,7 +353,7 @@ GHModelImporter >> parseFileTreeResult: aResult [
^ reader nextAs: #ArrayOfFile
]

{ #category : #private }
{ #category : #parsing }
GHModelImporter >> parseGroupResult: aResult [

| reader |
Expand All @@ -344,7 +366,7 @@ GHModelImporter >> parseGroupResult: aResult [
^ reader nextAs: GLHGroup
]

{ #category : #private }
{ #category : #parsing }
GHModelImporter >> parsePipelinesResult: pipelineOverview [

| reader |
Expand All @@ -366,6 +388,21 @@ GHModelImporter >> parsePipelinesResult: pipelineOverview [
^ reader nextAs: GHAPIPipelineOverview
]

{ #category : #parsing }
GHModelImporter >> parseProjectResult: aResult [

| reader |
reader := NeoJSONReader on: aResult readStream.
reader for: GLHProject do: [ :mapping |
mapping mapInstVar: #name to: #name.
mapping mapInstVar: #description to: #description.
mapping mapInstVar: #id to: #id.
mapping mapInstVar: #archived to: #archived.
mapping mapInstVar: #web_url to: #html_url.
mapping mapInstVar: #topics to: #topics ].
^ reader nextAs: GLHProject
]

{ #category : #parsing }
GHModelImporter >> parseUserResult: result [

Expand Down
Loading