Hello community, here is the log from the commit of package vgrep for openSUSE:Factory checked in at 2018-01-29 14:58:29 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/vgrep (Old) and /work/SRC/openSUSE:Factory/.vgrep.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "vgrep" Mon Jan 29 14:58:29 2018 rev:2 rq:570379 version:2.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/vgrep/vgrep.changes 2018-01-19 11:51:18.277035764 +0100 +++ /work/SRC/openSUSE:Factory/.vgrep.new/vgrep.changes 2018-01-29 15:00:11.470859152 +0100 @@ -1,0 +2,6 @@ +Sat Jan 27 11:54:17 UTC 2018 - [email protected] + +- Update vgrep v2.0.1 to v2.0.2 + https://github.com/vrothberg/vgrep/releases/tag/2.0.2 + +------------------------------------------------------------------- Old: ---- 2.0.1.tar.gz New: ---- 2.0.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ vgrep.spec ++++++ --- /var/tmp/diff_new_pack.dCiOs9/_old 2018-01-29 15:00:12.762798790 +0100 +++ /var/tmp/diff_new_pack.dCiOs9/_new 2018-01-29 15:00:12.762798790 +0100 @@ -1,7 +1,7 @@ # # spec file for package vgrep # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -21,13 +21,13 @@ # Project name when using go tooling. %define project github.com/vrothberg/vgrep Name: vgrep -Version: 2.0.1 +Version: 2.0.2 Release: 0 Summary: Frontend for git-grep and grep License: GPL-3.0 Group: Productivity/Text/Utilities -URL: https://github.com/vrothberg/vgrep -Source0: https://github.com/vrothberg/%{name}/archive/%{version}.tar.gz +Url: https://github.com/vrothberg/vgrep +Source0: https://github.com/vrothberg/vgrep/archive/%{version}.tar.gz BuildRequires: fdupes BuildRequires: golang(API) >= 1.6 Requires: git-core ++++++ 2.0.1.tar.gz -> 2.0.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vgrep-2.0.1/Makefile new/vgrep-2.0.2/Makefile --- old/vgrep-2.0.1/Makefile 2017-12-05 09:13:42.000000000 +0100 +++ new/vgrep-2.0.2/Makefile 2018-01-27 12:33:06.000000000 +0100 @@ -13,11 +13,11 @@ .PHONY: build build: $(GO_SRC) - $(GO) build -o $(BUILD_DIR)/$(NAME) -ldflags "-s -w -X main.version=${VERSION}-$(COMMIT)-dev" + $(GO) build -buildmode=pie -o $(BUILD_DIR)/$(NAME) -ldflags "-s -w -X main.version=${VERSION}-$(COMMIT)-dev" .PHONY: release release: $(GO_SRC) - $(GO) build -o $(BUILD_DIR)/$(NAME) -ldflags "-s -w -X main.version=${VERSION}" + $(GO) build -buildmode=pie -o $(BUILD_DIR)/$(NAME) -ldflags "-s -w -X main.version=${VERSION}" .PHONY: clean clean: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vgrep-2.0.1/VERSION new/vgrep-2.0.2/VERSION --- old/vgrep-2.0.1/VERSION 2017-12-05 09:13:42.000000000 +0100 +++ new/vgrep-2.0.2/VERSION 2018-01-27 12:33:06.000000000 +0100 @@ -1 +1 @@ -2.0.1 +2.0.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/vgrep-2.0.1/vgrep.go new/vgrep-2.0.2/vgrep.go --- old/vgrep-2.0.1/vgrep.go 2017-12-05 09:13:42.000000000 +0100 +++ new/vgrep-2.0.2/vgrep.go 2018-01-27 12:33:06.000000000 +0100 @@ -12,6 +12,7 @@ "io/ioutil" "os" "os/exec" + "path/filepath" "regexp" "sort" "strconv" @@ -213,8 +214,25 @@ } // cachePath returns the path to the user-specific vgrep cache. -func cachePath() string { - return os.Getenv("HOME") + "/.cache/vgrep-go" +func cachePath() (string, error) { + cache := filepath.Join(os.Getenv("HOME"), ".cache/") + exists := true + + if _, err := os.Stat(cache); err != nil { + if os.IsNotExist(err) { + exists = false + } else { + return "", err + } + } + + if !exists { + if err := os.Mkdir(cache, 0700); err != nil { + return "", err + } + } + + return filepath.Join(cache, "vgrep-go"), nil } // cacheWrite uses cacheWriterHelper to write to the user-specific vgrep cache. @@ -236,7 +254,11 @@ return fmt.Errorf("error getting working dir: %v", err) } - file, err := os.OpenFile(cachePath(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) + cache, err := cachePath() + if err != nil { + return fmt.Errorf("error getting cache path: %v", err) + } + file, err := os.OpenFile(cache, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755) if err != nil { return err } @@ -260,12 +282,19 @@ Log.Debug("loadCache(): start") defer Log.Debug("loadCache(): end") - file, err := ioutil.ReadFile(cachePath()) + cache, err := cachePath() + if err != nil { + return fmt.Errorf("error getting cache path: %v", err) + } + + file, err := ioutil.ReadFile(cache) if err != nil { return err } + if err := json.Unmarshal(file, &Matches); err != nil { - os.Remove(cachePath()) + // if there's an error unmarshalling it, remove the cache file + os.Remove(cache) return err }
