Skip to content

Check if branch is tracking branch before issuing push/pull during an 'update' operation #1

@lowell80

Description

@lowell80
  • Crispy Cookie version: 0.7.1
  • Python version: 3.9
  • Operating System: Mac

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Error output

Commiting....
[cookiecutter edc15b0] Update to cypress-cookiecutter@v1.10.0
 5 files changed, 18 insertions(+), 35 deletions(-)
git push
fatal: The current branch cookiecutter has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin cookiecutter

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

Traceback (most recent call last):
  File "/Users/lalleman/.pyenv/versions/3.9.16/bin/crispy_cookie", line 8, in <module>
    sys.exit(main())
  File "/Users/lalleman/.pyenv/versions/3.9.16/lib/python3.9/site-packages/crispy_cookie/cli.py", line 629, in main
    return args.function(args)
  File "/Users/lalleman/.pyenv/versions/3.9.16/lib/python3.9/site-packages/crispy_cookie/cli.py", line 497, in do_update
    upgrade_project(tc, project_dir, args.branch, config_file, do_build, remote_ops=args.remote)
  File "/Users/lalleman/.pyenv/versions/3.9.16/lib/python3.9/site-packages/crispy_cookie/rebase.py", line 125, in upgrade_project
    run([GIT_BIN, "push"], check=True)
  File "/Users/lalleman/.pyenv/versions/3.9.16/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'push']' returned non-zero exit status 128.

Possible command line to check to see if a branch is a remote tracking branch or not:

% git rev-parse --abbrev-ref cookiecutter@{upstream}; echo $? 
fatal: no upstream configured for branch 'cookiecutter'
128

If a remote tracking branch is added, then:

% git rev-parse --abbrev-ref cookiecutter@{upstream}; echo $?
origin/cookiecutter
0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions