Skip to content

CLI - Creating same bug fix branch name twice causes fireworks #32

@katzung-slac

Description

@katzung-slac

Tried creating a "fix-14" branch twice on the same repo - things went badly.
Don't know if preflighting might be possible/worthwhile, or if just a better/clearer error message can be produced.

This is the transcript from the second attempt to create a "fix-14" branch:

`(swfactory-env) [katzung@sdfiana008 oscilloscope]$ bs create branch --fix 14
Checking current directory if a component...
[?] Specify what to branch from:

branch
tag
commit

Specify name of branch: dev-patrick
INFO-root:[request.py:44 - log_api_response() ] 500
INFO-root:[request.py:45 - log_api_response() ] {'timestamp': '2024-11-06T00:26:30.544+00:00', 'status': 500, 'error': 'Internal Server Error', 'path': '/v1/component/oscilloscope/branch', 'errorCode': -2, 'errorMessage': 'The version label is not valid', 'errorDomain': 'ComponentService::addNewVersion'}
INFO-root:[request.py:46 - log_api_response() ] https://ad-build-dev.slac.stanford.edu/api/cbs/v1/component/oscilloscope/branch
INFO-root:[request.py:47 - log_api_response() ] b'{"type": "branch", "branchPoint": "dev-patrick", "branchName": "fix-14"}'
INFO-root:[request.py:48 - log_api_response() ] {'User-Agent': 'python-requests/2.31.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': '/', 'Connection': 'keep-alive', 'linux_username': 'katzung', 'github_username': 'katzung-slac', 'Content-Length': '72', 'Content-Type': 'application/json'}
Username for 'https://github.com': katzung-slac
Password for 'https://katzung-slac@github.com':
Cmd('git') failed due to: exit code(1)
cmdline: git push -u origin fix-14
stderr: 'To https://github.com/ad-build-test/Oscilloscope
! [rejected] fix-14 -> fix-14 (fetch first)
error: failed to push some refs to 'https://github.com/ad-build-test/Oscilloscope'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.'
Deleting branch...
Traceback (most recent call last):
File "/sdf/home/k/katzung/demo/BuildSystem/bs_cli/adbs_cli/component.py", line 41, in git_push
self.git_repo.git.push('-u', 'origin', branch_name)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 986, in
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 1598, in _call_process
return self.execute(call, **exec_kwargs)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 1388, in execute
raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git push -u origin fix-14
stderr: 'To https://github.com/ad-build-test/Oscilloscope
! [rejected] fix-14 -> fix-14 (fetch first)
error: failed to push some refs to 'https://github.com/ad-build-test/Oscilloscope'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/bin/bs", line 33, in
sys.exit(load_entry_point('adbs-cli', 'console_scripts', 'bs')())
File "/sdf/home/k/katzung/demo/BuildSystem/bs_cli/adbs_cli/bs_main.py", line 57, in main
entry_point(prog_name='bs')
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/sdf/home/k/katzung/demo/BuildSystem/bs_cli/adbs_cli/create_commands.py", line 160, in branch
if (component_obj.git_push(full_branch_name)):
File "/sdf/home/k/katzung/demo/BuildSystem/bs_cli/adbs_cli/component.py", line 46, in git_push
self.git_repo.git.branch('-D', branch_name)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 986, in
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 1598, in _call_process
return self.execute(call, **exec_kwargs)
File "/sdf/home/k/katzung/.conda/envs/swfactory-env/lib/python3.10/site-packages/git/cmd.py", line 1388, in execute
raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(1)
cmdline: git branch -D fix-14
stderr: 'error: Cannot delete branch 'fix-14' checked out at '/sdf/home/k/katzung/demo/oscilloscope''
`

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