Fix branch checking logic #204

Closed
Frando wants to merge 1 commits from Frando/abra:fix-branch-detection into main
First-time contributor

Hi,
I was playing with a local recipe (not part of the catalogue) and abra app deploy kept complaining with this error message: FATA[0002] failed to select default branch, even though the repo has a regular main branch.

I then went to debugging, and it turns out the repository.Branch() method somehow does not actually check for branch names, but instead only looks at the git config, where only remote-tracking branches are listed.

See https://github.com/go-git/go-git/issues/518 for details.

The attached patch fixes this and thus allows to deploy if main is not configured as a remote-tracking branch.

An alternative would be to display a more helpful error message if it's actually required that branches have to be configured as remote-tracking branches. Currently the error message failed to select default branch, while the repo clearly has a main branch, makes it hard to see what's going on (apart from diving into Go debugging which is new for me too, haven't been doing much in Go so far).

Thanks!
Frando

Hi, I was playing with a local recipe (not part of the catalogue) and `abra app deploy` kept complaining with this error message: `FATA[0002] failed to select default branch`, even though the repo has a regular main branch. I then went to debugging, and it turns out the `repository.Branch()` method somehow does not actually check for branch names, but instead only looks at the git config, where only remote-tracking branches are listed. See https://github.com/go-git/go-git/issues/518 for details. The attached patch fixes this and thus allows to deploy if `main` is not configured as a remote-tracking branch. An alternative would be to display a more helpful error message if it's actually required that branches have to be configured as remote-tracking branches. Currently the error message `failed to select default branch`, while the repo clearly has a `main` branch, makes it hard to see what's going on (apart from diving into Go debugging which is new for me too, haven't been doing much in Go so far). Thanks! Frando
Frando added 1 commit 2022-08-11 12:21:10 +00:00
Fix branch checking logic
All checks were successful
continuous-integration/drone/pr Build is passing
552ee5bbd9
See https://github.com/go-git/go-git/issues/518 for why this is needed.
decentral1se approved these changes 2022-08-11 15:47:48 +00:00
decentral1se left a comment
Owner

Thanks for diving into this! This looks legit 👍 The go-git API is pretty obscure, so easy to miss this one. I've run into random issues with the branch logic over time but couldn't really track it down... maybe this is it!

Thanks for diving into this! This looks legit 👍 The `go-git` API is pretty obscure, so easy to miss this one. I've run into random issues with the branch logic over time but couldn't really track it down... maybe this is it!
Owner

Merged in 8458e61d17 (with amended git commit message that matches the 'ol https://www.conventionalcommits.org/en/v1.0.0/ for the change log) and added you to https://git.coopcloud.tech/coop-cloud/abra/src/branch/main/AUTHORS.md. Thanks!

Merged in https://git.coopcloud.tech/coop-cloud/abra/commit/8458e61d170fcdff7b1744851f0da1111f845d87 (with amended git commit message that matches the 'ol https://www.conventionalcommits.org/en/v1.0.0/ for the change log) and added you to https://git.coopcloud.tech/coop-cloud/abra/src/branch/main/AUTHORS.md. Thanks!
decentral1se closed this pull request 2022-08-11 15:52:49 +00:00
All checks were successful
continuous-integration/drone/pr Build is passing

Pull request closed

Sign in to join this conversation.
No description provided.