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 New Branch from the commit #139

Closed
ib-ak opened this issue Feb 7, 2021 · 3 comments · Fixed by #140
Closed

Create New Branch from the commit #139

ib-ak opened this issue Feb 7, 2021 · 3 comments · Fixed by #140

Comments

@ib-ak
Copy link

ib-ak commented Feb 7, 2021

Is your feature request related to a problem? Please describe.
Action expects remote branch to be present. It tries to checkout the branch name.

Describe the solution you'd like
While switching to "branch" after fetch, if branch is not found,

  1. either, create a branch from checked out branch with new branch name and continue committing (use case: if user needs to work on newly created branch)
  2. or, commit first , create new branch later. (use case: user wants commit on both branches)
  3. or, commit to checked out branch and just add new branch name to git push without creating a new branch (use case: new brance is not used. user can still continue using checkout branch)
git push origin refs/heads/master:**missingBranch**

Describe alternatives you've considered
None

Additional context
Add any other context or screenshots about the feature request here.

@stefanzweifel
Copy link
Owner

Sorry, I can't quite follow your description here.
Am I right, that you're doing something link this in your workflow? (See pseudo-code below)

# At the start of the Workflow, the repo is checked out to the default branch
# by using actions/checkout@v2
git checkout main

# You then immediately create/switch to a new branch
git checkout -b other-branch

# You do a thing to your code which you want to automatically commit
touch foo.txt

# You then run git-auto-commit
stefanzweifel/git-auto-commit-action@v4

# You now expect that the `other-branch`-branch exists on GitHub with 
# the changes you made to your code.

It would be awesome if you could share more details of your Workflow or what you want to achieve.
We could then write a test case for that and maybe implement the necessary changes.

Meanwhile, have you tried using the branch config for the Action?

- uses: stefanzweifel/git-auto-commit-action@v4
  with:
    branch: feature-123

If you provide a branch option, the Action will create a new branch on remote.
https://github.com/stefanzweifel/git-auto-commit-action/blob/master/entrypoint.sh#L115

@ib-ak
Copy link
Author

ib-ak commented Feb 7, 2021

I think we are on same page.

I did try branch option with a new branch name
it fails here

git checkout $INPUT_BRANCH;

since that branch is not present it cannot do a checkout

@stefanzweifel
Copy link
Owner

@abhinavkhanna-sf I've created a PR with a possible solution in #140.

Could you please test this in your workflows by updating your workflows like this?

-- uses: stefanzweifel/git-auto-commit-action@v4
+- uses: stefanzweifel/git-auto-commit-action@feature/create-new-branch-during-checkout

If this solves the problem for you, I would tag a new release in the next days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants