From 949b2c3a9e9507afbaf7901b1943295d14f9b9b7 Mon Sep 17 00:00:00 2001 From: Jonathan Hurter Date: Tue, 2 Aug 2022 17:43:12 +0200 Subject: [PATCH] fix(appdetect) Do not crash if the git config has a remote without any URL Fix #754 --- CHANGELOG.md | 1 + utils/git.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d5606222..63756b161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * fix(error): interpret raw newline [#744](https://github.com/Scalingo/cli/pull/744) * fix(stats): display memory as IEC size [#742](https://github.com/Scalingo/cli/pull/742) * fix(autoscalers): min containers cannot be 1 [#741](https://github.com/Scalingo/cli/pull/741) +* fix(appdetect): Do not crash if there is a remote without any URL [#755](https://github.com/Scalingo/cli/pull/755) * refactor(run_unix): replace github.com/heroku/hk/term with golang.org/x/term [#740](https://github.com/Scalingo/cli/pull/740) * build(deps): bump github.com/stretchr/testify from 1.7.2 to 1.8.0 * build(deps): bump github.com/cheggaaa/pb/v3 from 3.0.8 to 3.1.0 diff --git a/utils/git.go b/utils/git.go index d1dbbf8c6..94217263a 100644 --- a/utils/git.go +++ b/utils/git.go @@ -63,6 +63,10 @@ func ScalingoGitRemotes(directory string) ([]*git.Remote, error) { matchedRemotes := []*git.Remote{} for _, remote := range remotes { + if len(remote.Config().URLs) == 0 { + continue + } + remoteURL := remote.Config().URLs[0] matched, err := regexp.Match(".*scalingo.com:.*.git", []byte(remoteURL)) if err != nil || !matched {