ksconf / ksconf/crispy_cookie

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

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

Nobody has claimed this yet.

Dominant language
Python
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

  • 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

Contributor guide

Open the contributing guide

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 in crispy_cookie/rebase.py at upgrade_project, where the update operation invokes git push, and review the reported git rev-parse upstream check. Reproduce the update with a branch lacking an upstream; done means the operation handles that case instead of issuing an unusable push or pull command.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.