From 78057987ffe2fbc8d6a231bc8de652d28d71a51a12d79dd0713700c2f4b61537 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Sat, 3 Aug 2024 17:27:38 +0200 Subject: [PATCH] Add remote-config.patch (gh#MichaelMure/git-bug!1076): try reading git-bug.remote config value before defaulting to 'origin' when no explicit REMOTE argument. --- git-bug.changes | 7 ++++ git-bug.spec | 3 ++ remote-config.patch | 100 ++++++++++++++++++++++++++++++++++++++++++++ vendor.tar.gz | 4 +- 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 remote-config.patch diff --git a/git-bug.changes b/git-bug.changes index faf6e3e..67b3f5e 100644 --- a/git-bug.changes +++ b/git-bug.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Sat Aug 3 15:16:21 UTC 2024 - Matej Cepl + +- Add remote-config.patch (gh#MichaelMure/git-bug!1076): try + reading git-bug.remote config value before defaulting to + 'origin' when no explicit REMOTE argument. + ------------------------------------------------------------------- Tue May 07 14:31:42 UTC 2024 - mcepl@cepl.eu diff --git a/git-bug.spec b/git-bug.spec index 18c4653..3b0a865 100644 --- a/git-bug.spec +++ b/git-bug.spec @@ -24,6 +24,9 @@ License: MIT URL: https://github.com/MichaelMure/git-bug # Source0: https://github.com/MichaelMure/%%{name}/archive/refs/tags/v%%{version}.tar.gz#/git-bug-%%{version}.tar.gz Source0: git-bug-%{version}.tar.gz +# PATCH-FIX-UPSTREAM remote-config.patch gh#MichaelMure/git-bug!1076 mcepl@suse.com +# try reading git-bug.remote config value before defaulting to 'origin' when no explicit REMOTE argument +Patch0: remote-config.patch Source1: vendor.tar.gz # # PATCH-FEATURE-UPSTREAM 501-export.patch gh#MichaelMure/git-bug!501 mcepl@suse.com # # add a command to export bugs as raw operations diff --git a/remote-config.patch b/remote-config.patch new file mode 100644 index 0000000..4cd834e --- /dev/null +++ b/remote-config.patch @@ -0,0 +1,100 @@ +From 65cfe2b3fff11d34b5ffc9f7e5d24aefb505497f Mon Sep 17 00:00:00 2001 +From: William Ahern +Date: Thu, 27 Jul 2023 22:06:45 -0700 +Subject: [PATCH] pull, push: try reading git-bug.remote config value before + defaulting to 'origin' when no explicit REMOTE argument + +--- + commands/pull.go | 16 +++++++++++----- + commands/push.go | 16 +++++++++++----- + repository/config.go | 11 +++++++++++ + 3 files changed, 33 insertions(+), 10 deletions(-) + +--- a/commands/pull.go ++++ b/commands/pull.go +@@ -8,6 +8,7 @@ import ( + "github.com/MichaelMure/git-bug/commands/completion" + "github.com/MichaelMure/git-bug/commands/execenv" + "github.com/MichaelMure/git-bug/entity" ++ "github.com/MichaelMure/git-bug/repository" + ) + + func newPullCommand(env *execenv.Env) *cobra.Command { +@@ -25,13 +26,18 @@ func newPullCommand(env *execenv.Env) *c + } + + func runPull(env *execenv.Env, args []string) error { +- if len(args) > 1 { ++ var remote string ++ switch { ++ case len(args) > 1: + return errors.New("Only pulling from one remote at a time is supported") +- } +- +- remote := "origin" +- if len(args) == 1 { ++ case len(args) == 1: + remote = args[0] ++ default: ++ v, err := repository.GetDefaultString("git-bug.remote", env.Repo.AnyConfig(), "origin") ++ if err != nil { ++ return err ++ } ++ remote = v + } + + env.Out.Println("Fetching remote ...") +--- a/commands/push.go ++++ b/commands/push.go +@@ -7,6 +7,7 @@ import ( + + "github.com/MichaelMure/git-bug/commands/completion" + "github.com/MichaelMure/git-bug/commands/execenv" ++ "github.com/MichaelMure/git-bug/repository" + ) + + func newPushCommand(env *execenv.Env) *cobra.Command { +@@ -24,13 +25,18 @@ func newPushCommand(env *execenv.Env) *c + } + + func runPush(env *execenv.Env, args []string) error { +- if len(args) > 1 { ++ var remote string ++ switch { ++ case len(args) > 1: + return errors.New("Only pushing to one remote at a time is supported") +- } +- +- remote := "origin" +- if len(args) == 1 { ++ case len(args) == 1: + remote = args[0] ++ default: ++ v, err := repository.GetDefaultString("git-bug.remote", env.Repo.AnyConfig(), "origin") ++ if err != nil { ++ return err ++ } ++ remote = v + } + + stdout, err := env.Backend.Push(remote) +--- a/repository/config.go ++++ b/repository/config.go +@@ -60,6 +60,17 @@ type ConfigWrite interface { + RemoveAll(keyPrefix string) error + } + ++func GetDefaultString(key string, cfg ConfigRead, def string) (string, error) { ++ val, err := cfg.ReadString(key) ++ if err == nil { ++ return val, nil ++ } else if errors.Is(err, ErrNoConfigEntry) { ++ return def, nil ++ } else { ++ return "", err ++ } ++} ++ + func ParseTimestamp(s string) (time.Time, error) { + timestamp, err := strconv.Atoi(s) + if err != nil { diff --git a/vendor.tar.gz b/vendor.tar.gz index b6ab2e4..ad81456 100644 --- a/vendor.tar.gz +++ b/vendor.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:20212cbdc6d9ca0461e8b47c6a459f9c061439252510fd0ffb9fdeb094651ab4 -size 6582254 +oid sha256:fb3ee611b914d7b1632914d5e15464f07d2094c3eb0abaa6b08c97a7d486e550 +size 6758351