Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def update_refs(

refs = action_refs[name]
if new_ref not in refs:
for _, details in refs.items():
for ref_key, details in list(refs.items()):
if details is None:
refs[ref_key] = details = {}
if not details.get("keep"):
new_expiry = calculate_expiry(12)
if "expires_at" not in details or details["expires_at"] > new_expiry:
Expand Down
17 changes: 17 additions & 0 deletions gateway/test_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ def test_update_refs():
update_refs(steps, refs)
assert refs == expected_refs

def test_update_refs_none_details():
steps = load_yaml_string('''
- uses: carabiner-dev/actions/install/ampel-bootstrap@9db1a064ca5691ef6f5d983031739ca287de0968
''')

refs: ActionsYAML = load_yaml_string('''
carabiner-dev/actions/install/ampel-bootstrap:
0a075bb75a68646d05f99c85cbbf2be40dd8e442:
''')

update_refs(steps, refs)

bootstrap = refs["carabiner-dev/actions/install/ampel-bootstrap"]
assert bootstrap["0a075bb75a68646d05f99c85cbbf2be40dd8e442"]["expires_at"] == calculate_expiry(12)
assert "9db1a064ca5691ef6f5d983031739ca287de0968" in bootstrap


def test_update_refs_expiry():
steps = [
{"uses": "dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36"},
Expand Down