From 061e83d4b4aa66c2691b3699a3e770b2a58d26df Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Mon, 24 Sep 2018 16:24:38 +0200 Subject: commands: add "bridge rm" --- repository/git.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'repository/git.go') diff --git a/repository/git.go b/repository/git.go index 51c4f46b..af251aa2 100644 --- a/repository/git.go +++ b/repository/git.go @@ -170,8 +170,14 @@ func (repo *GitRepo) StoreConfig(key string, value string) error { func (repo *GitRepo) ReadConfigs(keyPrefix string) (map[string]string, error) { stdout, err := repo.runGitCommand("config", "--get-regexp", keyPrefix) + // / \ + // / ! \ + // ------- + // + // There can be a legitimate error here, but I see no portable way to + // distinguish them from the git error that say "no matching value exist" if err != nil { - return nil, err + return nil, nil } lines := strings.Split(stdout, "\n") @@ -194,6 +200,13 @@ func (repo *GitRepo) ReadConfigs(keyPrefix string) (map[string]string, error) { return result, nil } +// RmConfigs remove all key/value pair matching the key prefix +func (repo *GitRepo) RmConfigs(keyPrefix string) error { + _, err := repo.runGitCommand("config", "--remove-section", keyPrefix) + + return err +} + // FetchRefs fetch git refs from a remote func (repo *GitRepo) FetchRefs(remote, refSpec string) (string, error) { stdout, err := repo.runGitCommand("fetch", remote, refSpec) -- cgit v1.2.3