-
-
Notifications
You must be signed in to change notification settings - Fork 782
Description
SUMMARY
When running packs.get against a pack that uses main as the main branch, the action errors out on:
git rev-list --left-right --count HEAD...origin/master
STACKSTORM VERSION
st2 3.7.0, on Python 3.8.10
st2 3.8.1, on Python 3.8.10
OS, environment, install method
This is happening in the st2-docker environment and on Ubuntu Focal 20.04.6 LTS.
Steps to reproduce the problem
You can verify this with st2-docker most easily. Create a new pack as a git repository that has main as the main branch. export ST2_PACKS_DEV to point to the folder where you create the new pack before starting up docker-compose. Then run:
st2 run packs.get pack=test_pack
Expected Results
I would expect something like this as output:
st2 run packs.get pack=test_pack
.
id: 66a285f3d8efba08aebc802b
action.ref: packs.get
context.user: st2admin
parameters:
pack: test_pack
status: succeeded
start_timestamp: Thu, 25 Jul 2024 17:05:55 UTC
end_timestamp: Thu, 25 Jul 2024 17:05:55 UTC
result:
exit_code: 0
result:
git_status: null
pack:
author: jpavlav
contributors:
- Justin Palmer
dependencies:
- core
description: Pack for testing cuz
email: jpalmer@digitalocean.com
keywords:
- testing
name: test_pack
python_versions:
- '3'
ref: test_pack
version: 0.0.1
stderr: ''
stdout: ''
Actual Results
.
id: 66a285e4d8efba08aebc8028
action.ref: packs.get
context.user: st2admin
parameters:
pack: test_pack
status: failed
start_timestamp: Thu, 25 Jul 2024 17:05:40 UTC
end_timestamp: Thu, 25 Jul 2024 17:05:41 UTC
result:
exit_code: 1
result: None
stderr: "Traceback (most recent call last):
File "/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py", line 395, in <module>
obj.run()
File "/opt/stackstorm/st2/lib/python3.8/site-packages/python_runner/python_action_wrapper.py", line 214, in run
output = action.run(**self._parameters)
File "/opt/stackstorm/packs/packs/actions/pack_mgmt/get_installed.py", line 73, in run
ahead_behind = repo.git.rev_list(
File "/opt/stackstorm/st2/lib/python3.8/site-packages/git/cmd.py", line 739, in <lambda>
return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
File "/opt/stackstorm/st2/lib/python3.8/site-packages/git/cmd.py", line 1315, in _call_process
return self.execute(call, **exec_kwargs)
File "/opt/stackstorm/st2/lib/python3.8/site-packages/git/cmd.py", line 1110, in execute
raise GitCommandError(redacted_command, status, stderr_value, stdout_value)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
cmdline: git rev-list --left-right --count HEAD...origin/master
stderr: 'fatal: ambiguous argument 'HEAD...origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]''
"
stdout: ''
This is caused by this line. There is an assumption that the main branch is master, but this is likely to become less and less common over time.
It should be easy enough to fix, but just updating the action to include a branch_name or main_branch parameter and then turning the argument into a format string that includes the input from the user. Plus, it might be nice to actually catch this error and provide some better feedback about why it failed.