From 10d5205734c8bd721feed2a178e87f734c072202 Mon Sep 17 00:00:00 2001 From: Gareth Evans Date: Wed, 3 Feb 2021 17:15:52 +0000 Subject: [PATCH] chore: fix on rebase when remote endswith .git --- pkg/domain/git.go | 3 +++ pkg/domain/rebase_test.go | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/pkg/domain/git.go b/pkg/domain/git.go index b3be306..e11fcfd 100644 --- a/pkg/domain/git.go +++ b/pkg/domain/git.go @@ -186,6 +186,9 @@ func ExtractURLFromRemote(reader io.Reader, name string) (string, error) { } func ExtractOrgAndRepoURL(urlString string) (string, string, error) { + if strings.HasSuffix(urlString, ".git") { + urlString = strings.TrimSuffix(urlString, ".git") + } url, err := url2.Parse(urlString) if err != nil { return "", "", err diff --git a/pkg/domain/rebase_test.go b/pkg/domain/rebase_test.go index 2cae820..03839d2 100644 --- a/pkg/domain/rebase_test.go +++ b/pkg/domain/rebase_test.go @@ -106,6 +106,22 @@ upstream https://github.com/upstream/repo (push)`, "https://api.github.com/repos/upstream/repo", }, }, + { + name: "simple rebase on main with .git extension", + remotes: `origin https://github.com/origin/clone.git (fetch) +origin https://github.com/origin/clone.git (push)`, + originDefaultBranch: "main", + expectedCommands: []string{ + "git remote -v", + "git remote -v", + "git status --porcelain", + "git branch --show-current", + "git pull --tags origin main", + }, + expectedRequests: []string{ + "https://api.github.com/repos/origin/clone", + }, + }, } for _, tc := range tests {