forked from pool/git-bug
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.
This commit is contained in:
parent
ed232a54e3
commit
78057987ff
@ -1,3 +1,10 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Aug 3 15:16:21 UTC 2024 - Matej Cepl <mcepl@cepl.eu>
|
||||||
|
|
||||||
|
- 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
|
Tue May 07 14:31:42 UTC 2024 - mcepl@cepl.eu
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ License: MIT
|
|||||||
URL: https://github.com/MichaelMure/git-bug
|
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: https://github.com/MichaelMure/%%{name}/archive/refs/tags/v%%{version}.tar.gz#/git-bug-%%{version}.tar.gz
|
||||||
Source0: 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
|
Source1: vendor.tar.gz
|
||||||
# # PATCH-FEATURE-UPSTREAM 501-export.patch gh#MichaelMure/git-bug!501 mcepl@suse.com
|
# # PATCH-FEATURE-UPSTREAM 501-export.patch gh#MichaelMure/git-bug!501 mcepl@suse.com
|
||||||
# # add a command to export bugs as raw operations
|
# # add a command to export bugs as raw operations
|
||||||
|
100
remote-config.patch
Normal file
100
remote-config.patch
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
From 65cfe2b3fff11d34b5ffc9f7e5d24aefb505497f Mon Sep 17 00:00:00 2001
|
||||||
|
From: William Ahern <william@25thandClement.com>
|
||||||
|
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 {
|
BIN
vendor.tar.gz
(Stored with Git LFS)
BIN
vendor.tar.gz
(Stored with Git LFS)
Binary file not shown.
Loading…
Reference in New Issue
Block a user