managedkaos / managedkaos/merge-pull-request

The action fails if the main branch already exists

Open
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
7
Forks
2
PR merge metrics
No merged PRs in 30d

Description

I believe there is an issue on **entrypoint.sh**. I used this action to merge a pull request that was previously auto approved. In my GitHub repository, my principal branch is main and there is a command in the entrypoint.sh in line 41.

git checkout -b "${HEAD_BRANCH}" origin/"${HEAD_BRANCH}"

This produces this error:
fatal: a branch named 'main' already exists

This could be overcome with the following code:

if git branch --list | grep -q "${HEAD_BRANCH}"; then
echo "Branch ${HEAD_BRANCH} already exists, checking it out."
git checkout "${HEAD_BRANCH}"
else
echo "Creating a new branch ${HEAD_BRANCH}."
git checkout -b "${HEAD_BRANCH}" origin/"${HEAD_BRANCH}"
fi

The indentation of the above snipped is not working while writing the issue.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with entrypoint.sh around line 41 and reproduce the action with a repository whose principal branch is already named main. Check the branch-selection behavior when ${HEAD_BRANCH} already exists, then verify the action can continue its pull-request merge without the fatal branch-name error.

Written by the indexing model from the issue text.

Assessment

Tech stack
shell
Domain
ci-cd
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.