Prevent creating an already existing branch. by jackton1 · Pull Request #97 · pre-commit/action

@jackton1

Resolves error pushing to the current branch for private repositories

Screen Shot 2021-04-20 at 7 00 51 PM

    -b <branch>           create and checkout a new branch
    -B <branch>           create/reset and checkout a branch

@jackton1

@jackton1 jackton1 changed the title Prevent checking out an already existing branch. Prevent creating an already existing branch.

Apr 20, 2021

@asottile

can you share an example workflow? from my testing this shouldn't be necessary and/or can overwrite other work

@jackton1

Yeah had the same thought unable to get more information from the logs

2021-04-20T22:47:51.0456035Z Flake8.....................................................................�[42mPassed�[m
2021-04-20T22:47:51.0457452Z �[2m- hook id: flake8�[m
2021-04-20T22:47:51.0458319Z �[2m- duration: 8.51s�[m
2021-04-20T22:47:51.2094758Z Check for usage of lambda functions in the migration.......................�[42mPassed�[m
2021-04-20T22:47:51.2096698Z �[2m- hook id: no-lambda-in-migration�[m
2021-04-20T22:47:51.2098195Z �[2m- duration: 0.16s�[m
2021-04-20T22:47:51.2325261Z [command]/usr/bin/git diff --quiet
2021-04-20T22:47:51.2435364Z ##[group]push fixes
2021-04-20T22:47:51.2460747Z [command]/usr/bin/git config user.name pre-commit
2021-04-20T22:47:51.2523324Z [command]/usr/bin/git config user.email pre-commit@example.com
2021-04-20T22:47:51.2581953Z [command]/usr/bin/git checkout HEAD -b feature/dropped-the-dynamic-section-variant-fill-mode
2021-04-20T22:47:51.2615873Z fatal: A branch named 'feature/dropped-the-dynamic-section-variant-fill-mode' already exists.
2021-04-20T22:47:51.2619910Z ##[endgroup]
2021-04-20T22:47:51.2626371Z ##[error]The process '/usr/bin/git' failed with exit code 128
2021-04-20T22:47:51.2756907Z Post job cleanup.

Running on v2.0.0 if that helps

...
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0
    
    - name: Pre-commit
      uses: pre-commit/action@v2.0.0
      with:
        extra_args: -v --hook-stage push --all-files
        token: ${{ secrets.github_token }}

asottile

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like this was an intentional change as part of actions/checkout@v2 -- I guess we can accept the forcible checkout 🤷