From ee7a0010905154effd19b4e4a6adc8800310c7b1 Mon Sep 17 00:00:00 2001
From: Kamil Trzcinski <ayufan@ayufan.eu>
Date: Sun, 22 Nov 2015 13:35:44 +0100
Subject: [PATCH] Fix caching support

- Fix broken tar unpack command
- Suppress tar verbose output
---
 CHANGELOG.md        |  4 ++++
 VERSION             |  2 +-
 commands/archive.go | 14 ++++++++------
 shells/bash.go      | 11 ++++++-----
 4 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index e380ef03f..b3fc4ca40 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+v 0.7.1
+- Fix caching support
+- Suppress tar verbose output
+
 v 0.7.0
 - Refactor code structure
 - Refactor bash script adding pre-build and post-build steps
diff --git a/VERSION b/VERSION
index faef31a43..39e898a4f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.7.0
+0.7.1
diff --git a/commands/archive.go b/commands/archive.go
index 0834c910d..06bacb722 100644
--- a/commands/archive.go
+++ b/commands/archive.go
@@ -109,6 +109,7 @@ func (c *ArchiveCommand) processUntracked() {
 	cmd.Env = os.Environ()
 	cmd.Stdout = &output
 	cmd.Stderr = os.Stderr
+	logrus.Debugln("Executing command:", strings.Join(cmd.Args, " "))
 	err := cmd.Run()
 	if err == nil {
 		reader := bufio.NewReader(&output)
@@ -133,7 +134,7 @@ func (c *ArchiveCommand) archive() {
 		return
 	}
 
-	logrus.Infoln("Creating archive", c.Output, "...")
+	logrus.Infoln("Creating archive", filepath.Base(c.Output), "...")
 	var files bytes.Buffer
 	for _, file := range c.sortedFiles() {
 		files.WriteString(string(file) + "\n")
@@ -149,7 +150,7 @@ func (c *ArchiveCommand) archive() {
 	tempFile.Close()
 	defer os.Remove(tempFile.Name())
 
-	logrus.Debugln("Temporary file", tempFile.Name())
+	logrus.Debugln("Temporary file:", tempFile.Name())
 
 	flags := "-zcPv"
 	if c.Silent {
@@ -161,14 +162,15 @@ func (c *ArchiveCommand) archive() {
 	cmd.Stdin = &files
 	cmd.Stdout = os.Stdout
 	cmd.Stderr = os.Stderr
+	logrus.Debugln("Executing command:", strings.Join(cmd.Args, " "))
 	err = cmd.Run()
 	if err != nil {
-		logrus.Fatalln("Failed to create archive", err)
+		logrus.Fatalln("Failed to create archive:", err)
 	}
 
 	err = os.Rename(tempFile.Name(), c.Output)
 	if err != nil {
-		logrus.Warningln("Failed to rename archive", err)
+		logrus.Warningln("Failed to rename archive:", err)
 	}
 
 	logrus.Infoln("Done!")
@@ -184,7 +186,7 @@ func (c *ArchiveCommand) Execute(context *cli.Context) {
 
 	wd, err := os.Getwd()
 	if err != nil {
-		logrus.Fatalln("Failed to get current working directory", err)
+		logrus.Fatalln("Failed to get current working directory:", err)
 	}
 	if c.Output == "" {
 		logrus.Fatalln("Missing archive file name!")
@@ -198,7 +200,7 @@ func (c *ArchiveCommand) Execute(context *cli.Context) {
 
 	ai, err := os.Stat(c.Output)
 	if err != nil && !os.IsNotExist(err) {
-		logrus.Fatalln("Failed to verify archive", c.Output, err)
+		logrus.Fatalln("Failed to verify archive:", c.Output, err)
 	}
 	if ai != nil {
 		if !c.isChanged(ai.ModTime()) {
diff --git a/shells/bash.go b/shells/bash.go
index 2ac1a4262..2f6427f87 100644
--- a/shells/bash.go
+++ b/shells/bash.go
@@ -153,14 +153,14 @@ func (b *BashShell) generatePreBuildScript(info common.ShellScriptInfo) string {
 		// If we have cache, restore it
 		b.writeIfFile(w, cacheFile)
 		b.echoColored(w, "Restoring cache...")
-		b.executeCommand(w, "tar", "-zxfv", "-f", cacheFile)
+		b.executeCommand(w, "tar", "-zxf", cacheFile)
 		if cacheFile2 != "" {
 			b.writeElse(w)
 
 			// If we have cache, restore it
 			b.writeIfFile(w, cacheFile2)
 			b.echoColored(w, "Restoring cache...")
-			b.executeCommand(w, "tar", "-zxfv", "-f", cacheFile2)
+			b.executeCommand(w, "tar", "-zxf", cacheFile2)
 			b.writeEndIf(w)
 		}
 		b.writeEndIf(w)
@@ -205,7 +205,8 @@ func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, arc
 
 	args := []string{
 		"archive",
-		"-output",
+		"--silent",
+		"--output",
 		archivePath,
 	}
 
@@ -213,14 +214,14 @@ func (b *BashShell) archiveFiles(w io.Writer, list interface{}, archiveType, arc
 	if paths, ok := hash["paths"].([]interface{}); ok {
 		for _, artifactPath := range paths {
 			if file, ok := artifactPath.(string); ok {
-				args = append(args, "-path", file)
+				args = append(args, "--path", file)
 			}
 		}
 	}
 
 	// Archive also untracked files
 	if untracked, ok := hash["untracked"].(bool); ok && untracked {
-		args = append(args, "-untracked")
+		args = append(args, "--untracked")
 	}
 
 	// Skip creating archive
-- 
GitLab