From d0059fcb87312d296a31d6965d6db84e499fe020 Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Mon, 17 Apr 2023 14:43:15 +0200 Subject: Only use compact URL in UI, not in written files many tools like eg some vscode extensions can parse the git remotes but do not respect git aliases and fail to understand shorthands like gh:majewsky/gofu --- internal/rtree/get_test.go | 8 ++++---- internal/rtree/remote.go | 2 +- internal/rtree/repo.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'internal') diff --git a/internal/rtree/get_test.go b/internal/rtree/get_test.go index a438234..789e903 100644 --- a/internal/rtree/get_test.go +++ b/internal/rtree/get_test.go @@ -35,7 +35,7 @@ var testIndexWithTwoRepos = Index{ { CheckoutPath: "github.com/git/git", Remotes: []Remote{ - {Name: "origin", URL: "gh:git/git"}, + {Name: "origin", URL: "https://github.com/git/git"}, }, }, }, @@ -65,14 +65,14 @@ func TestGetNewRepo(t *testing.T) { Args: []string{"get", remoteURL}, Index: testIndexWithTwoRepos, ExpectOutput: target + "\n", - ExpectExecution: Recorded("git clone gh:another/repo " + target), + ExpectExecution: Recorded("git clone https://github.com/another/repo " + target), ExpectIndex: &Index{ Repos: []*Repo{ { CheckoutPath: "github.com/another/repo", Remotes: []Remote{ //regardless of the remote URL used, we expect the contracted form to be used - {Name: "origin", URL: "gh:another/repo"}, + {Name: "origin", URL: "https://github.com/another/repo"}, }, }, testIndexWithTwoRepos.Repos[0], @@ -106,7 +106,7 @@ func TestGetNewForkAsRemote(t *testing.T) { { CheckoutPath: "github.com/git/git", Remotes: []Remote{ - {Name: "origin", URL: "gh:git/git"}, + {Name: "origin", URL: "https://github.com/git/git"}, {Name: "myfork", URL: "https://example.com/git"}, }, }, diff --git a/internal/rtree/remote.go b/internal/rtree/remote.go index 2973b8c..36e12dd 100644 --- a/internal/rtree/remote.go +++ b/internal/rtree/remote.go @@ -104,7 +104,7 @@ func (u RemoteURL) CheckoutPath() (string, error) { // MarshalYAML implements the yaml.Marshaler interface. func (u RemoteURL) MarshalYAML() (interface{}, error) { //store URLs in the index in the compact format - return u.CompactURL(), nil + return u.CanonicalURL(), nil } // UnmarshalYAML implements the yaml.Unmarshaler interface. diff --git a/internal/rtree/repo.go b/internal/rtree/repo.go index 5cdd39f..2267666 100644 --- a/internal/rtree/repo.go +++ b/internal/rtree/repo.go @@ -153,7 +153,7 @@ func (r Repo) Checkout() error { cli.Interface.ShowWarning(`will not checkout anything since there is no remote named "origin"`) } else { err := cli.Interface.Run(cli.Command{ - Program: []string{"git", "clone", originURL.CompactURL(), r.AbsolutePath()}, + Program: []string{"git", "clone", originURL.CanonicalURL(), r.AbsolutePath()}, }) if err != nil { return err @@ -164,7 +164,7 @@ func (r Repo) Checkout() error { for _, remote := range r.Remotes { if remote.Name != "origin" { err := cli.Interface.Run(cli.Command{ - Program: []string{"git", "remote", "add", remote.Name, remote.URL.CompactURL()}, + Program: []string{"git", "remote", "add", remote.Name, remote.URL.CanonicalURL()}, WorkDir: r.AbsolutePath(), }) if err != nil { @@ -234,7 +234,7 @@ func (r *Repo) Move(checkoutPath string, makeSymlink bool) error { func (r Repo) ReformatRemoteURLs() error { for _, remote := range r.Remotes { err := cli.Interface.Run(cli.Command{ - Program: []string{"git", "remote", "set-url", remote.Name, remote.URL.CompactURL()}, + Program: []string{"git", "remote", "set-url", remote.Name, remote.URL.CanonicalURL()}, WorkDir: r.AbsolutePath(), }) if err != nil { -- cgit v1.3.1