Skip to content

Commit 24dff81

Browse files
committed
Issue #37: initial cut at adding preview support
1 parent 1dc689b commit 24dff81

13 files changed

+225
-168
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ jobs:
188188
name: Post Workflow Status To Slack
189189
needs:
190190
- build
191-
runs-on: ubuntu-24.04
191+
runs-on: ubuntu-latest
192192
steps:
193193
- name: Slack Workflow Notification
194194
uses: Gamesight/slack-workflow-status@master

bin/cloneProjectsFromProjectSet.solo

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ SuperDoitOptionalOptionWithRequiredArg long: 'registry' short: 'r'.
55
SuperDoitOptionalOptionWithRequiredArg long: 'remote' default: 'origin'.
66
SuperDoitRequiredOptionWithRequiredArg long: 'projectSet'.
77
SuperDoitOptionalOptionWithRequiredArg long: 'projectDirectory'.
8+
SuperDoitOptionalOptionWithNoArg long: 'preview'.
89
SuperDoitOptionalOptionWithNoArg long: 'update'.
910
}
1011
%
@@ -43,6 +44,9 @@ OPTIONS
4344
Path to directory where the projects will be cloned. If not
4445
specified the projectDirectory associated with the project set
4546
is used.
47+
--preview If present log whether or not a pull request is needed. Useful
48+
to manually review the state of projects PRIOR to doing a pull
49+
request.
4650
--update If present, a pull request will be issued for the origin remote
4751
to update the repository to the latest version of the branch
4852
available.
@@ -57,6 +61,7 @@ EXAMPLES
5761
$basename
5862
$basename --registry=bosch --projectSet=dev --remote=https Rowan \
5963
--projectDirectory=/home/dhenrich/bosch1/_exp_git
64+
$basename -r=bosch --projectSet=_stones Rowan --preview
6065
$basename -r=bosch --projectSet=_stones Rowan --update
6166
-----
6267
%
@@ -113,9 +118,9 @@ doit
113118
projectDir asFileReference ensureCreateDirectory.
114119
Rowan projectTools trace startTracing.
115120
self positionalArgs size = 0
116-
ifTrue: [ projectSet cloneOrUpdateProjectSet: projectDir remoteName: self remote pull: self update]
121+
ifTrue: [ projectSet cloneOrUpdateProjectSet: projectDir remoteName: self remote preview: self preview pull: self update]
117122
ifFalse: [
118123
self positionalArgs do: [:projectName |
119-
projectSet cloneOrUpdateProject: projectName remoteName: self remote in: projectDir pull: self update] ].
124+
projectSet cloneOrUpdateProject: projectName remoteName: self remote in: projectDir preview: self preview pull: self update] ].
120125
true
121126
%
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
installation
22
cloneOrUpdateProject: projectName in: gitRootPath
33
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4-
has already been cloned, then checkout the revision specified in the load spec"
4+
has already been cloned, then checkout the revision specified in the load spec and display a message about whether or not a pull request is needed"
55

6-
self cloneOrUpdateProject: projectName remoteName: 'origin' in: gitRootPath pull: false
6+
self cloneOrUpdateProject: projectName remoteName: 'origin' in: gitRootPath preview: true pull: false
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
installation
22
cloneOrUpdateProject: projectName in: gitRootPath pull: pull
33
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4-
has already been cloned, then checkout the revision specified in the load spec"
4+
has already been cloned, then checkout the revision specified in the load spec. If pull is true, then perform a pull request
5+
to update to the latest branch. If pull is false, print a message indicating whether or not a pull request is needed."
56

6-
self cloneOrUpdateProject: projectName remoteName: 'origin' in: gitRootPath pull: pull
7+
self cloneOrUpdateProject: projectName remoteName: 'origin' in: gitRootPath preview: pull not pull: pull
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
installation
22
cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath
33
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4-
has already been cloned, then checkout the revision specified in the load spec"
4+
has already been cloned, then checkout the revision specified in the load spec. Display a message about whether
5+
or not a pull request is needed"
56

6-
self cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath pull: false
7+
self cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath preview: true pull: false
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
installation
2+
cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath flag: flag pull: pull
3+
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4+
has already been cloned, then checkout the revision specified in the load spec"
5+
6+
| gitTool specDict gitUrls gitProjectRef gitUrl cloned |
7+
gitTool := Rowan gitTools.
8+
specDict := self loadSpecs at: projectName.
9+
gitUrls := specDict at: 'gitUrls'.
10+
gitUrl := gitUrls at: remoteName.
11+
gitProjectRef := gitRootPath asFileReference / projectName.
12+
cloned := false.
13+
gitProjectRef exists
14+
ifTrue: [
15+
(Rowan gitTools gitstatusIn: gitProjectRef fullName with: '--porcelain') isEmpty
16+
not
17+
ifTrue: [
18+
"the git repository has unsaved modifications, so abort the operation"
19+
self
20+
error:
21+
'There are unsaved changes in ' , gitProjectRef fullName printString
22+
, '. We cannot clone or update a repository with unsaved chnages' ] ]
23+
ifFalse: [
24+
| originArg |
25+
"GIT CLONE"
26+
originArg := ''.
27+
remoteName ~= 'origin'
28+
ifTrue: [ originArg := ' --origin ' , remoteName , ' ' ].
29+
gitTool gitcloneIn: gitRootPath with: originArg , gitUrl logging: true.
30+
cloned := true ].
31+
(specDict at: 'revision' ifAbsent: [ ])
32+
ifNotNil: [ :revision |
33+
Transcript
34+
cr;
35+
show: ' Set ' , projectName , ' revision to ' , revision.
36+
cloned
37+
ifTrue: [
38+
"GIT SWITCH"
39+
gitTool
40+
performGitCommand: 'switch'
41+
in: gitProjectRef fullName
42+
with: ' ' , remoteName , '/' , revision , ' -t -C ' , revision ]
43+
ifFalse: [
44+
flag ifTrue: [
45+
"GIT SWITCH
46+
GIT PULL"
47+
Transcript
48+
cr;
49+
show:
50+
' FLAG: ' , projectName , ' revision ' , revision , ' from remote ' , remoteName ].
51+
pull
52+
ifTrue: [
53+
"GIT SWITCH
54+
GIT PULL"
55+
gitTool
56+
performGitCommand: 'switch'
57+
in: gitProjectRef fullName
58+
with: ' ' , remoteName , '/' , revision , ' -t -C ' , revision.
59+
Transcript
60+
cr;
61+
show:
62+
' Pull ' , projectName , ' revision ' , revision , ' from remote ' , remoteName.
63+
gitTool
64+
gitpullIn: gitProjectRef fullName
65+
remote: remoteName
66+
branch: revision ] ] ].
67+
cloned
68+
ifTrue: [
69+
"GIT REMOTE ADD"
70+
(gitUrls keys reject: [ :each | each = remoteName ])
71+
do: [ :theRemote |
72+
self
73+
gitAddRemoteIn: gitProjectRef fullName
74+
remote: theRemote
75+
gitUrl: (gitUrls at: theRemote) ]. "GIT FETCH --all"
76+
Transcript
77+
cr;
78+
show: ' Fetch --all '.
79+
gitTool gitfetchIn: gitProjectRef with: ' --all' ]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
installation
2+
cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath preview: preview
3+
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4+
has already been cloned, then checkout the revision specified in the load spec. If preview is true display a message
5+
about whether or not a pull request is needed"
6+
7+
self
8+
cloneOrUpdateProject: projectName
9+
remoteName: remoteName
10+
in: gitRootPath
11+
preview: preview
12+
pull: false
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
installation
2+
cloneOrUpdateProject: projectName remoteName: remoteName in: gitRootPath preview: preview pull: pull
3+
"Clone the named project into the gitRootPath directory using the information in the load spec for project. If the project
4+
has already been cloned, then checkout the revision specified in the load spec. If preview is true display a message
5+
about whether or not a pull request is needed. If pull is true, perform the pull request."
6+
7+
| gitTool specDict gitUrls gitProjectRef gitUrl cloned |
8+
gitTool := Rowan gitTools.
9+
specDict := self loadSpecs at: projectName.
10+
gitUrls := specDict at: 'gitUrls'.
11+
gitUrl := gitUrls at: remoteName.
12+
gitProjectRef := gitRootPath asFileReference / projectName.
13+
cloned := false.
14+
gitProjectRef exists
15+
ifTrue: [
16+
(Rowan gitTools gitstatusIn: gitProjectRef fullName with: '--porcelain') isEmpty
17+
not
18+
ifTrue: [
19+
"the git repository has unsaved modifications, so abort the operation"
20+
self
21+
error:
22+
'There are unsaved changes in ' , gitProjectRef fullName printString
23+
, '. We cannot clone or update a repository with unsaved chnages' ] ]
24+
ifFalse: [
25+
| originArg |
26+
"GIT CLONE"
27+
originArg := ''.
28+
remoteName ~= 'origin'
29+
ifTrue: [ originArg := ' --origin ' , remoteName , ' ' ].
30+
gitTool gitcloneIn: gitRootPath with: originArg , gitUrl logging: true.
31+
cloned := true ].
32+
(specDict at: 'revision' ifAbsent: [ ])
33+
ifNotNil: [ :revision |
34+
Transcript
35+
cr;
36+
show: ' Set ' , projectName , ' revision to ' , revision.
37+
cloned
38+
ifTrue: [
39+
"GIT SWITCH"
40+
gitTool
41+
performGitCommand: 'switch'
42+
in: gitProjectRef fullName
43+
with: ' ' , remoteName , '/' , revision , ' -t -C ' , revision ]
44+
ifFalse: [
45+
preview ifTrue: [
46+
"GIT SWITCH
47+
GIT PULL"
48+
Transcript
49+
cr;
50+
show:
51+
' PREVIEW: PULL' , projectName , ' revision ' , revision , ' from remote ' , remoteName ].
52+
pull
53+
ifTrue: [
54+
"GIT SWITCH
55+
GIT PULL"
56+
gitTool
57+
performGitCommand: 'switch'
58+
in: gitProjectRef fullName
59+
with: ' ' , remoteName , '/' , revision , ' -t -C ' , revision.
60+
Transcript
61+
cr;
62+
show:
63+
' Pull ' , projectName , ' revision ' , revision , ' from remote ' , remoteName.
64+
gitTool
65+
gitpullIn: gitProjectRef fullName
66+
remote: remoteName
67+
branch: revision ] ] ].
68+
cloned
69+
ifTrue: [
70+
"GIT REMOTE ADD"
71+
(gitUrls keys reject: [ :each | each = remoteName ])
72+
do: [ :theRemote |
73+
self
74+
gitAddRemoteIn: gitProjectRef fullName
75+
remote: theRemote
76+
gitUrl: (gitUrls at: theRemote) ]. "GIT FETCH --all"
77+
Transcript
78+
cr;
79+
show: ' Fetch --all '.
80+
gitTool gitfetchIn: gitProjectRef with: ' --all' ]

0 commit comments

Comments
 (0)