Skip to content

Commit

Permalink
Fix packs.get action (#6226)
Browse files Browse the repository at this point in the history
* Fix `packs.get` action

Addresses #6225. This should allow users to specify a branch when using
the `packs.get` command. This addresses the assumption in the code that
the primary branch of a git repository corresponding to an action is
`master`.

* Add `branch` parameter to `get.yaml`. Default to `master` to maintain
current functionality/expectations.
* Update `run` in `pack_mgmt.get_install.py`. Now accepts `branch` param
and uses an `fstring` to represent the in `git rev list`.

* Update Changelog
  • Loading branch information
jpavlav authored Sep 9, 2024
1 parent b905ea2 commit 69ad38b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Python 3.6 is no longer supported; Stackstorm requires at least Python 3.8.

Fixed
~~~~~
* Fix `packs.get` action. Assumed `master` is primary branch on all packs. #6225
* Restore Pack integration testing (it was inadvertently skipped) and stop testing against `bionic` and `el7`. #6135
* Fix Popen.pid typo in st2tests. #6184
* Bump tooz package to `6.2.0` to fix TLS. #6220 (@jk464)
Expand Down
5 changes: 5 additions & 0 deletions contrib/packs/actions/get.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ parameters:
type: "string"
description: "Name of pack to lookup"
required: true
branch:
type: "string"
description: "The primary branch of this pack repo"
required: false
default: "master"
6 changes: 3 additions & 3 deletions contrib/packs/actions/pack_mgmt/get_installed.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
class GetInstalled(Action):
"""Get information about installed pack."""

def run(self, pack):
def run(self, pack, branch):
"""
:param pack: Installed Pack Name to get info about
:type pack: ``str``
:type branch: ``str``
"""
packs_base_paths = get_packs_base_paths()

Expand Down Expand Up @@ -69,9 +70,8 @@ def run(self, pack):
repo.git.status().split("\n")[0],
"\n".join([remote.url for remote in repo.remotes]),
)

ahead_behind = repo.git.rev_list(
"--left-right", "--count", "HEAD...origin/master"
"--left-right", "--count", f"HEAD...origin/{branch}"
).split()
# Dear god.
if ahead_behind != ["0", "0"]:
Expand Down

0 comments on commit 69ad38b

Please sign in to comment.