-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
analytics: fix git remote reporting (#1145)
- Loading branch information
Showing
2 changed files
with
26 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package cli | ||
|
||
import ( | ||
"os/exec" | ||
"testing" | ||
|
||
"github.com/windmilleng/tilt/internal/testutils/tempdir" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
|
@@ -21,3 +24,22 @@ func TestNormalizeGitRemoteTrailingSlash(t *testing.T) { | |
func TestNormalizedGitRemoteUsername(t *testing.T) { | ||
assert.Equal(t, normalizeGitRemote("https://github.com/windmilleng/tilt"), normalizeGitRemote("[email protected]:windmilleng/tilt.git")) | ||
} | ||
|
||
func TestGitOrigin(t *testing.T) { | ||
tf := tempdir.NewTempDirFixture(t) | ||
defer tf.TearDown() | ||
|
||
err := exec.Command("git", "init", tf.Path()).Run() | ||
if err != nil { | ||
t.Fatalf("failed to init git repo: %+v", err) | ||
} | ||
err = exec.Command("git", "-C", tf.Path(), "remote", "add", "origin", "https://github.com/windmilleng/tilt").Run() | ||
if err != nil { | ||
t.Fatalf("failed to set origin's url: %+v", err) | ||
} | ||
origin := gitOrigin(tf.Path()) | ||
|
||
// we can't just compare raw urls because of https://git-scm.com/docs/git-config#git-config-urlltbasegtinsteadOf | ||
// e.g., circleci images set `url.ssh://[email protected]=https://github.com` | ||
assert.Equal(t, "//github.com/windmilleng/tilt", normalizeGitRemote(origin)) | ||
} |