aboutsummaryrefslogtreecommitdiffstats
path: root/config/config_test.go
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2024-08-27 12:02:32 +0200
committerMatěj Cepl <mcepl@cepl.eu>2024-09-02 18:18:12 +0200
commit8c1e320dd40c8f99df46bdf0f1097d2365485519 (patch)
treea02ced29f8b3c5497733f75d0c040d62746ef5f1 /config/config_test.go
parent5c762aefcd8dded79e25bc2055254b4146e2b5a9 (diff)
downloadgo-git-push_url.tar.gz
fix: collect also push URLsHEADpush_url
This is a hack: we should collect pull URLs and push URLs (if any) separately and use the appropriate ones, or perhaps add a flag to each URL, whether it is capable of pushing. Also, add test for the remote URLs (pull and push)
Diffstat (limited to 'config/config_test.go')
-rw-r--r--config/config_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/config/config_test.go b/config/config_test.go
index 7e9483f..6f011e0 100644
--- a/config/config_test.go
+++ b/config/config_test.go
@@ -371,3 +371,27 @@ func (s *ConfigSuite) TestRemoveUrlOptions(c *C) {
}
c.Assert(err, IsNil)
}
+
+func (s *ConfigSuite) TestUnmarshalRemotes(c *C) {
+ input := []byte(`[core]
+ bare = true
+ worktree = foo
+ custom = ignored
+[user]
+ name = John Doe
+ email = john@example.com
+[remote "origin"]
+ url = https://git.sr.ht/~mcepl/go-git
+ pushurl = git@git.sr.ht:~mcepl/go-git.git
+ fetch = +refs/heads/*:refs/remotes/origin/*
+ mirror = true
+`)
+
+ cfg := NewConfig()
+ err := cfg.Unmarshal(input)
+ c.Assert(err, IsNil)
+
+ c.Assert(cfg.Remotes["origin"].URLs[0], Equals, "https://git.sr.ht/~mcepl/go-git")
+ c.Assert(cfg.Remotes["origin"].URLs[1], Equals, "git@git.sr.ht:~mcepl/go-git.git")
+}
+