Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a branch if it doesn't exist #202

Closed
palewire opened this issue Feb 18, 2022 · 5 comments
Closed

Create a branch if it doesn't exist #202

palewire opened this issue Feb 18, 2022 · 5 comments
Labels
duplicate This issue or pull request already exists enhancement New feature or request

Comments

@palewire
Copy link

I'd like to be able to list branch names not yet in the repo and have them work out of the box. Right now if I do that I get an error at the checkout step.

Would you be open to a test that would look if the branch already exists before checking out, and then creates a new branch with checkout -b if it doesn't?

@stefanzweifel stefanzweifel added duplicate This issue or pull request already exists enhancement New feature or request labels Feb 19, 2022
@stefanzweifel
Copy link
Owner

stefanzweifel commented Feb 19, 2022

@palewire Sounds like a good idea. Feel free to send a PR with such a test.

I already tried this in #140, but broke the Action for others in this step. See comments in #142.

Or feel free to share a workflow, where the Action fails. Always great to see, how others use the Action and in what scenarios it fails.

@palewire
Copy link
Author

Interesting, what if we kept your basic logic but substituted in this test

git show-ref --verify --quiet refs/heads/<branch-name>

which is the recommended method in this Stack Overflow thread.

@stefanzweifel
Copy link
Owner

@palewire Will give this a try over the next few days. Have neglected working on this action for a couple of weeks now. Time to get up to speed an close these issues.

Might also hide this "feature" behind an option. Breaking the Action for the now +22k users is not something I want to do. 😄

@stefanzweifel
Copy link
Owner

stefanzweifel commented Feb 23, 2022

@palewire I've prepared something in #203. Test suite and first tests in real applications seem to work fine. Feel free to give this solution a try by updating your workflows like this:

    - uses: stefanzweifel/git-auto-commit-action@master
      with:
        branch: YOUR_BRANCH_NAME_GOES_HERE
        create_branch: true

As the feature is behind a feature flag, I feel confident enough to merge this soonish.

@stefanzweifel
Copy link
Owner

I've merged the feature to the master branch; but haven't tagged a new version yet.
In the past, I've made the mistake and tagged a release too soon and broke Workflows for users.
I will tag a new version in the next 1-2 weeks, if no bug reports are coming in.

In the meantime, feel free to use the stefanzweifel/git-auto-commit-action@master as mentioned in the comment above.

Closing this issue now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants