From de4860463388df28ba5546f6ea072afdbe92c066 Mon Sep 17 00:00:00 2001 From: Loic Reyreaud Date: Mon, 14 Oct 2019 10:56:33 +0200 Subject: [PATCH 1/2] change ref used in git to compute diff to AURUTILS_SEEN Introduce a global constant in download.go to avoid re-typing the string everytime. Change the string form YAY_DIFF_SEEN to AURUTILS_SEEN. --- download.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/download.go b/download.go index 8a24872..675ef3b 100644 --- a/download.go +++ b/download.go @@ -14,6 +14,10 @@ import ( "github.com/Jguer/yay/v9/pkg/types" ) +const ( + gitDiffRefName = "AURUTILS_SEEN" +) + // Decide what download method to use: // Use the config option when the destination does not already exits // If .git exists in the destination use git @@ -51,7 +55,7 @@ func downloadFile(path string, url string) (err error) { // Update the YAY_DIFF_REVIEW ref to HEAD. We use this ref to determine which diff were // reviewed by the user func gitUpdateSeenRef(path string, name string) error { - _, stderr, err := capture(passToGit(filepath.Join(path, name), "update-ref", "YAY_DIFF_REVIEW", "HEAD")) + _, stderr, err := capture(passToGit(filepath.Join(path, name), "update-ref", gitDiffRefName, "HEAD")) if err != nil { return fmt.Errorf("%s%s", stderr, err) } @@ -61,7 +65,7 @@ func gitUpdateSeenRef(path string, name string) error { // Return wether or not we have reviewed a diff yet. It checks for the existence of // YAY_DIFF_REVIEW in the git ref-list func gitHasLastSeenRef(path string, name string) bool { - _, _, err := capture(passToGit(filepath.Join(path, name), "rev-parse", "--quiet", "--verify", "YAY_DIFF_REVIEW")) + _, _, err := capture(passToGit(filepath.Join(path, name), "rev-parse", "--quiet", "--verify", gitDiffRefName)) return err == nil } @@ -69,7 +73,7 @@ func gitHasLastSeenRef(path string, name string) bool { // If it does not it will return empty tree as no diff have been reviewed yet. func getLastSeenHash(path string, name string) (string, error) { if gitHasLastSeenRef(path, name) { - stdout, stderr, err := capture(passToGit(filepath.Join(path, name), "rev-parse", "YAY_DIFF_REVIEW")) + stdout, stderr, err := capture(passToGit(filepath.Join(path, name), "rev-parse", gitDiffRefName)) if err != nil { return "", fmt.Errorf("%s%s", stderr, err) } @@ -84,7 +88,7 @@ func getLastSeenHash(path string, name string) (string, error) { // HEAD@{upstream} func gitHasDiff(path string, name string) (bool, error) { if gitHasLastSeenRef(path, name) { - stdout, stderr, err := capture(passToGit(filepath.Join(path, name), "rev-parse", "YAY_DIFF_REVIEW", "HEAD@{upstream}")) + stdout, stderr, err := capture(passToGit(filepath.Join(path, name), "rev-parse", gitDiffRefName, "HEAD@{upstream}")) if err != nil { return false, fmt.Errorf("%s%s", stderr, err) } From 21d0f33dae2ebeabb50f8e60296d971e93d90291 Mon Sep 17 00:00:00 2001 From: Loic Reyreaud Date: Tue, 15 Oct 2019 10:02:10 +0200 Subject: [PATCH 2/2] Change ref name used for marking reviewed diff to AUR_SEEN --- download.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/download.go b/download.go index 675ef3b..9d328f4 100644 --- a/download.go +++ b/download.go @@ -14,9 +14,7 @@ import ( "github.com/Jguer/yay/v9/pkg/types" ) -const ( - gitDiffRefName = "AURUTILS_SEEN" -) +const gitDiffRefName = "AUR_SEEN" // Decide what download method to use: // Use the config option when the destination does not already exits