-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Behavior and Cause
When you have an action triggered by a push to a certain branch, say my_branch
, and another similarly named branch exists, say another/my_branch
, getLocalRef
will return another/my_branch
instead of my_branch
as it shows up first in the list of matching refs pulled by getLocalRef
:
const output = (await exec('git', ['show-ref', shortName], {ignoreReturnCode: true})).stdout
const refs = output.split(/\r?\n/g)
.map(l =>; l.match(/refs\/.*$/)?.[0] ?? '')
.filter(l =>; l !== '')
Prefixing with this format{some_prefix}/{branch_name}
causes some trouble with show-ref
as they show up as refs for {branch_name}
. Annoyingly, some bots will autogenerate branches with this pattern, e.g., changeset actions has a bot that does such a thing (see example below).
Example
This was caused by the changeset bot:
Comment
I'm not sure what the right solution is here, I'd be happy to work together to figure it out but I'm not an expert in actions or git in general. It does appear to be an undesirable behavior that can get by you rather silently. I think you can solve this in some cases by explicitly passing the ref
in the inputs but does it make sense to fail if say there remoteRef.length > 1
in getLocalRef
?