Open abatilo opened 1 year ago
I can see there are two things that went wrong:
parsed branch metadata
, it seems that the parent of a topic branch is set to master
instead of main
. I'm not sure how this was set. Simple grepping the source code apparently doesn't have a hard coded master
in the repository. I have no idea on this.pushing to origin/main
, it seems that av-cli tries to push to main, which is wrong. https://github.com/aviator-co/av/blob/9b993bb53f138f6fe1af37605dacbbabd4f90ae7/internal/actions/pr.go#L107 suggests that the CLI assumes that "the upstream is where the branch should be pushed to", but probably this is not the case. Per git-core's documentation, https://git-scm.com/docs/git-branch/2.13.7#Documentation/git-branch.txt---track sets the upstream to where it's branching off e.g. main
, so it's more consistent to use the upstream tracking branch as "the target branch that a PR should be merged to". This behavior is also consistent to git pull
, which does merge the tracking branches into the local branch https://git-scm.com/docs/git-config#Documentation/git-config.txt-branchltnamegtmerge.
push.default = upstream
option as described at https://git-scm.com/docs/git-push#Documentation/git-push.txt-pushdefault. As you can see, the Git default option is simple
, which does "pushing to the same name branch on the remote". Assuming that most of Git users wouldn't even know this option exist, following the default behavior would be safer option.Actually, I feel like the repository has master
and main
branches at the same time. Can you check that?
Actually, I feel like the repository has
master
andmain
branches at the same time. Can you check that?
@draftcode sorry for the delay. It does not appear that this is the case:
⇒ git branch -a | rg "(main|master)"
main
remotes/origin/ecr-describeimages-pipeline-master
remotes/origin/main
remotes/origin/ryanking/tf-run-all-on-master
This was a repo that USED to have master
as the default branch but we switched it. Could that be causing a problem?
Ohhhhh interesting. @draftcode. Look at the output of:
⇒ av stack tree
master
main
Import-datadog-namespace
Reference-namespace-resource-for-pg-secret
For some reason, master is still in the av tree? I don't know how this is possible when there isn't a master branch at all.
I tracked the problem down to this line: https://github.com/aviator-co/av/blob/9b993bb53f138f6fe1af37605dacbbabd4f90ae7/internal/git/git.go#L41
If you have a repo that had a previous default branch name. Like in my case our repo used to have a default branch named master
, and then you switch to main
, the output of the command git symbolic-ref refs/remotes/origin/HEAD
will still point to the original branch name.
If I run the below command:
⇒ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
⇒ git symbolic-ref refs/remotes/origin/HEAD
refs/remotes/origin/main
Then you can see that my symbolic-ref
has been updated correctly also.
Maybe this should have a check for this error case? Thanks!
I have a repo whose base branch is
main
instead ofmaster
and when I try to submit I get the following output:Which, when I enable debug logging, appears to be because av is calling
git rev-list --reverse master..HEAD
instead ofmain..HEAD