prepare-upload-args does not handle error when remote branch cannot be fast-forwarded

Bug #2015488 reported by Athos Ribeiro
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
git-ubuntu
Fix Released
Undecided
Robie Basak

Bug Description

When a branch changes locally, trying to use prepare-upload args crashes if a previous upload was performed using the same branch name.

While this is expected in most cases, it may be an issue when sponsoring uploads since the git-ubuntu user (i.e., the uploader) will not interact directly with their own remote/branch.

We could improve the experience here by providing a better error message or asking if the user want to retry with a force push.

$ dpkg-buildpackage -S -nc -v27.13.6 $(git ubuntu prepare-upload args)
To ssh://git.launchpad.net/~athos-ribeiro/ubuntu/+source/ubuntu-advantage-tools
 ! [rejected] upload-27.14.4-jammy -> upload-27.14.4-jammy (non-fast-forward)
error: failed to push some refs to 'ssh://<email address hidden>/~athos-ribeiro/ubuntu/+source/ubuntu-advantage-tools'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
04/06/2023 11:19:41 - ERROR:Command exited 1: git push athos-ribeiro refs/heads/upload-27.14.4-jammy:refs/heads/upload-27.14.4-jammy
04/06/2023 11:19:41 - ERROR:stdout: [Not captured]

04/06/2023 11:19:41 - ERROR:stderr: [Not captured]

Traceback (most recent call last):
  File "/snap/git-ubuntu/1175/usr/bin/git-ubuntu", line 11, in <module>
    load_entry_point('gitubuntu==1.0', 'console_scripts', 'git-ubuntu')()
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/__main__.py", line 270, in main
    sys.exit(args.func(args))
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/prepare_upload.py", line 170, in cli_printargs
    headers = push(
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/prepare_upload.py", line 125, in push
    repo.git_run(
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/git_repository.py", line 1841, in git_run
    return git_run(
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/git_repository.py", line 267, in git_run
    return run(['git'] + list(args), env=env, **kwargs)
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/run.py", line 87, in run
    raise e
  File "/snap/git-ubuntu/1175/usr/lib/python3/dist-packages/gitubuntu/run.py", line 64, in run
    cp = subprocess.run(
  File "/snap/git-ubuntu/1175/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['git', 'push', 'athos-ribeiro', 'refs/heads/upload-27.14.4-jammy:refs/heads/upload-27.14.4-jammy']' returned non-zero exit status 1.
dpkg-buildpackage: info: source package ubuntu-advantage-tools
dpkg-buildpackage: info: source version 27.14.4~22.04
dpkg-buildpackage: info: source distribution jammy
dpkg-buildpackage: info: source changed by Renan Rodrigo <email address hidden>
 dpkg-source --before-build .
dpkg-buildpackage: warning: building a source package without cleaning up as you asked; it might contain undesired files
 dpkg-source -b .
dpkg-source: info: using source format '3.0 (native)'
dpkg-source: info: building ubuntu-advantage-tools in ubuntu-advantage-tools_27.14.4~22.04.tar.xz
dpkg-source: info: building ubuntu-advantage-tools in ubuntu-advantage-tools_27.14.4~22.04.dsc
 dpkg-genbuildinfo --build=source -O../ubuntu-advantage-tools_27.14.4~22.04_source.buildinfo
 dpkg-genchanges --build=source -v27.13.6 -O../ubuntu-advantage-tools_27.14.4~22.04_source.changes
dpkg-genchanges: warning: 'since' option specifies non-existing version '27.13.6'
dpkg-genchanges: warning: use newest entry that is earlier than the one specified
dpkg-genchanges: warning: the current version (27.14.4~22.04) is earlier than the previous one (27.14.4)
dpkg-genchanges: info: including full source code in upload
 dpkg-source --after-build .
dpkg-buildpackage: info: source-only upload: Debian-native package
 signfile ubuntu-advantage-tools_27.14.4~22.04.dsc
 signfile ubuntu-advantage-tools_27.14.4~22.04_source.buildinfo
 signfile ubuntu-advantage-tools_27.14.4~22.04_source.changes

Related branches

Robie Basak (racb)
tags: added: prepare-upload
Robie Basak (racb)
summary: - prepare-upload-args does not handle errors when remote branch differs
+ prepare-upload-args does not handle error when remote branch cannot be
+ fast-forwarded
Changed in git-ubuntu:
status: New → In Progress
assignee: nobody → Robie Basak (racb)
Revision history for this message
Robie Basak (racb) wrote :

Fixed in 1.1.

Changed in git-ubuntu:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.