Skip to content

Commit 7ca46e1

Browse files
committed
fix the cli paths
1 parent cf013ee commit 7ca46e1

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

cli/pkg/spec/spec.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"log"
1818
"os"
1919
"os/exec"
20-
"strings"
2120
"time"
2221
)
2322

@@ -186,18 +185,25 @@ func RunSpecManualCommand(
186185
usage.ReportErrorAndExit(spec.VCS.Actor, fmt.Sprintf("could not download job artefact: %v", err), 1)
187186
}
188187
zipPath := *absoluteFileName
189-
utils.ExtractZip(zipPath, tempDir)
190-
// Transforming: /var/temp/xxx/yyy/blabla.zip -> /var/temp/xxx/yyy/blabla
191-
gitLocation := strings.TrimSuffix(zipPath, ".zip")
192-
log.Printf("git location is: %v", gitLocation)
193-
log.Printf("zipPath: %v", zipPath)
194-
f, err := os.Stat(tempDir)
195-
log.Printf("files in %v : %v ", tempDir, f)
196-
197-
err = os.Chdir(gitLocation)
198-
if err != nil {
199-
log.Printf("Could not chdir: %v", err)
200-
usage.ReportErrorAndExit(spec.VCS.Actor, fmt.Sprintf("could not change directory: %v", err), 1)
188+
err = utils.ExtractZip(zipPath, tempDir)
189+
if err != nil {
190+
log.Printf("ExtractZip err: %v", err)
191+
usage.ReportErrorAndExit(spec.VCS.Actor, fmt.Sprintf("artefact zip extraction err: %v", err), 1)
192+
193+
}
194+
195+
// remove the zipPath
196+
err = os.Remove(zipPath)
197+
if err != nil {
198+
log.Printf("os.Remove err: %v", err)
199+
usage.ReportErrorAndExit(spec.VCS.Actor, fmt.Sprintf("zip path removal err: %v", err), 1)
200+
}
201+
202+
// Navigating to our diractory
203+
err = os.Chdir(tempDir)
204+
if err != nil {
205+
log.Printf("Chdir err: %v", err)
206+
usage.ReportErrorAndExit(spec.VCS.Actor, fmt.Sprintf("Chdir err: %v", err), 1)
201207
}
202208

203209
cmd := exec.Command("git", "init")

0 commit comments

Comments
 (0)