Skip to content

Commit

Permalink
Fix packs.get action
Browse files Browse the repository at this point in the history
Addresses StackStorm#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`.
  • Loading branch information
jpavlav committed Jul 25, 2024
1 parent 3e8426e commit a465ab0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
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 a465ab0

Please sign in to comment.