Skip to content
This repository was archived by the owner on Jan 25, 2022. It is now read-only.

Commit a562edf

Browse files
committed
updated
1 parent 46733ac commit a562edf

File tree

5 files changed

+94
-46
lines changed

5 files changed

+94
-46
lines changed

.idea/workspace.xml

+23-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ endif
2727

2828

2929
test:
30-
@./bin/deploywp run --chdir --json tests/deploywp.json
30+
@./bin/deploywp run --chdir --json tests/deploywp.json prod
3131

3232

3333
docker:

jsonTemplate/helpers/deploywp/helpers_highlevel.go

+58-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ func (e *TypeDeployWp) PrintPaths() *ux.State {
4848
// Usage:
4949
// {{ $cmd := OpenSourceRepo }}
5050
// {{ $cmd.ExitOnWarning }}
51-
func (e *TypeDeployWp) OpenSourceRepo() *ux.State {
51+
func (e *TypeDeployWp) OpenSourceRepo() *helperGit.HelperGit {
52+
gitRef := helperGit.NewGit().Reflect()
53+
5254
for range only.Once {
5355
if e.IsNil() {
5456
e.State.SetError("deploywp JSON is nil")
@@ -85,7 +87,7 @@ func (e *TypeDeployWp) OpenSourceRepo() *ux.State {
8587
break
8688
}
8789

88-
gitRef := helperGit.HelperNewGit()
90+
gitRef = helperGit.HelperNewGit()
8991
if gitRef.State.IsError() {
9092
e.State = gitRef.State
9193
break
@@ -128,6 +130,60 @@ func (e *TypeDeployWp) OpenSourceRepo() *ux.State {
128130
e.State.Clear()
129131
}
130132

133+
gitRef.State = e.State
134+
return gitRef
135+
}
136+
137+
138+
// Usage:
139+
// {{ $cmd := CheckoutSourceRepo }}
140+
// {{ $cmd.ExitOnWarning }}
141+
func (e *TypeDeployWp) CheckoutSourceRepo(gitRef *helperGit.HelperGit) *ux.State {
142+
for range only.Once {
143+
if e.IsNil() {
144+
e.State.SetError("deploywp JSON is nil")
145+
break
146+
}
147+
148+
if gitRef.IsNotExisting() {
149+
e.State.SetError("deploywp JSON is nil")
150+
break
151+
}
152+
153+
ux.PrintfBlue("# Checkout branch/tag from repository.\n")
154+
refType := e.Source.GetRevisionType()
155+
if refType == "" {
156+
e.State.SetError(".source.revision.ref_type is nil")
157+
break
158+
}
159+
160+
refName := e.Source.GetRevisionName()
161+
if refName == "" {
162+
e.State.SetError(".source.revision.ref_name is nil")
163+
break
164+
}
165+
166+
ux.PrintfBlue("# Source repository checkout.\n")
167+
ux.PrintfOk("Type: '%s'\n", refType)
168+
ux.PrintfOk("Name: '%s'\n", refName)
169+
170+
ux.PrintfBlue("# Checking if %s exists.\n", refType)
171+
e.State = gitRef.TagExists(refName)
172+
if e.State.IsError() {
173+
break
174+
}
175+
176+
ux.PrintfBlue("# Checking out %s:%s.\n", refType, refName)
177+
e.State = gitRef.TagExists(refName)
178+
if e.State.IsError() {
179+
break
180+
}
181+
182+
ux.PrintfOk("# Source repository opened OK.\n")
183+
e.State.Clear()
184+
}
185+
186+
gitRef.State = e.State
131187
return e.State
132188
}
133189

jsonTemplate/helpers/deploywp/helpers_workflow.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ func (e *TypeDeployWp) Run() *ux.State {
121121
ux.PrintfWhite("#############################\n")
122122
ux.PrintfWhite("# Opening source repository #\n")
123123
ux.PrintfWhite("#############################\n")
124-
e.State = e.OpenSourceRepo()
125-
if e.State.IsError() {
124+
srcGitRef := e.OpenSourceRepo()
125+
if srcGitRef.State.IsError() {
126126
break
127127
}
128128
ux.PrintfWhite("\n\n")
@@ -131,6 +131,13 @@ func (e *TypeDeployWp) Run() *ux.State {
131131
ux.PrintfWhite("#############################\n")
132132
ux.PrintfWhite("# Opening target repository #\n")
133133
ux.PrintfWhite("#############################\n")
134+
srcGitRef.State = e.CheckoutSourceRepo(srcGitRef)
135+
if e.State.IsError() {
136+
break
137+
}
138+
ux.PrintfWhite("\n\n")
139+
140+
134141
}
135142

136143
return e.State

jsonTemplate/helpers/helperGit/helpers_repository.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@ func (g *HelperGit) IsExisting() bool {
133133

134134
return ok
135135
}
136-
136+
func (g *HelperGit) IsNotExisting() bool {
137+
return !g.IsExisting()
138+
}
137139

138140
// Usage:
139141
// {{- $cmd := $git.Open }}

0 commit comments

Comments
 (0)