@@ -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.
@@ -40,6 +40,11 @@ inputs:
4040 description : ' Whether the stash_directory should be removed before downloading the stash.'
4141 default : ' false'
4242
43+ only-current-branch :
44+ description : >
45+ If true, only the current branch will be searched for the stash.
46+ If false, the base branch(PRs)/default branch branch will be searched as well.
47+ default : " false"
4348outputs :
4449 stash-hit :
4550 description : >
8287 m.output_munged_name(output = 'stash_head')
8388 m.output_munged_name(ref = 'base_ref', output = 'stash_base')
8489 with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
85- f.write(f'stash_path={os.path.abspath(os.environ["stash_path"])}' + '\n')
90+ f.write(f'stash_path={os.path.abspath(os.path.expanduser(os. environ["stash_path"]) )}' + '\n')
8691
8792 - name : Check for stash artifact
8893 id : check-stash
98103 head_name : " ${{ steps.mung.outputs.stash_head }}"
99104 run_id : " ${{ github.run_id }}"
100105 stash_key : " ${{ inputs.key }}"
106+ only_current_branch : " ${{ inputs.only-current-branch }}"
101107
102108 shell : python3 {0}
103109 run : |
@@ -116,9 +122,11 @@ runs:
116122 stash = gs.get_branch_stash(repo, head_name, env("head_ref"), env("head_repo_id"))
117123
118124 if not stash:
119- gs.print_debug(f"Looking for stash {base_name} on base branch.")
120- stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
121-
125+ if env("only_current_branch") == "true":
126+ print("Skipping base branch search as only-current-branch was set to true.")
127+ else:
128+ gs.print_debug(f"Looking for stash {base_name} on base branch.")
129+ stash = gs.get_branch_stash(repo, base_name, env("base_ref"), env("base_repo_id"))
122130 gs.print_debug(f"Stash: {stash}")
123131 if not stash:
124132 print(f"Stash not found for key: {env('stash_key')}")
0 commit comments