@@ -22,8 +22,8 @@ inputs:
2222 functionality as there is no eviction (only expiry).
2323
2424 The action checks the current branch for a stash, if there is no match,
25- the base branch(PRs)/default branch is searched. If there is more than one
26- match for any branch the most recently updated stash takes precedent.
25+ the base branch(PRs)/default branch is searched unless it's specified not to.
26+ If there is more than one match for any branch the most recently updated stash takes precedent.
2727
2828 To reduce amount of api calls (1000/h/repo limit) the name of the
2929 current branch will be appended to the key. Key and branchname will be normalized.
@@ -36,6 +36,12 @@ inputs:
3636 token :
3737 description : ' GITHUB_TOKEN to use to authenticate against the artifacts api.'
3838 default : ${{ github.token }}
39+
40+ only-current-branch :
41+ description : >
42+ If true, only the current branch will be searched for the stash.
43+ If false, the base branch(PRs)/default branch branch will be searched as well.
44+ default : " false"
3945outputs :
4046 stash-hit :
4147 description : >
94100 head_name : " ${{ steps.mung.outputs.stash_head }}"
95101 run_id : " ${{ github.run_id }}"
96102 stash_key : " ${{ inputs.key }}"
103+ only_current_branch : " ${{ inputs.only-current-branch }}"
97104
98105 shell : python3 {0}
99106 run : |
@@ -112,9 +119,11 @@ runs:
112119 stash = gs.get_branch_stash(repo, head_name, env("head_ref"), env("head_repo_id"))
113120
114121 if not stash:
115- gs.print_debug(f"Looking for stash {base_name} on base branch.")
116- stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
117-
122+ if env("only_current_branch") == "true":
123+ print("Skipping base branch search as only-current-branch was set to true.")
124+ else:
125+ gs.print_debug(f"Looking for stash {base_name} on base branch.")
126+ stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
118127 gs.print_debug(f"Stash: {stash}")
119128 if not stash:
120129 print(f"Stash not found for key: {env('stash_key')}")
0 commit comments