Compare commits

...

5 Commits

Author SHA1 Message Date
Alfonso Acosta
f4d0e73605
Merge f6b63ceb9e79ee917ff77ed8ef9f79097ad2cfc6 into 692973e3d937129bcbf40652eb9f2f61becf3332 2024-06-14 11:37:38 +00:00
Josh Gross
692973e3d9
Prepare 4.1.7 release (#1775)
Some checks failed
Check dist / check-dist (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Licensed / Check licenses (push) Has been cancelled
Build and Test / build (push) Has been cancelled
Build and Test / test (macos-latest) (push) Has been cancelled
Build and Test / test (ubuntu-latest) (push) Has been cancelled
Build and Test / test (windows-latest) (push) Has been cancelled
Build and Test / test-proxy (push) Has been cancelled
Build and Test / test-bypass-proxy (push) Has been cancelled
Build and Test / test-git-container (push) Has been cancelled
* Prepare 4.1.7 release

* Include #1776 in 4.1.7 release
2024-06-12 14:41:43 -04:00
John Wesley Walker III
6ccd57f4c5
Pin actions/checkout's own workflows to a known, good, stable version. (#1776)
* Pin actions/checkout's own workflows to a known, good, stable version.

* fixed failing unit test

* fix unit test
2024-06-12 13:11:03 -04:00
Orhan Toy
b17fe1e4d5
Handle hidden refs (#1774)
Some checks failed
Check dist / check-dist (push) Waiting to run
Licensed / Check licenses (push) Waiting to run
Build and Test / build (push) Waiting to run
Build and Test / test (macos-latest) (push) Waiting to run
Build and Test / test (ubuntu-latest) (push) Waiting to run
Build and Test / test (windows-latest) (push) Waiting to run
Build and Test / test-proxy (push) Waiting to run
Build and Test / test-bypass-proxy (push) Waiting to run
Build and Test / test-git-container (push) Waiting to run
CodeQL / Analyze (javascript) (push) Has been cancelled
Co-authored-by: Chris Gavin <chris@chrisgavin.me>
2024-06-12 11:01:40 -04:00
Alfonso Acosta
f6b63ceb9e
Make 'checkout pull request HEAD' example work for non-PRs 2022-03-02 20:23:19 +01:00
12 changed files with 43 additions and 19 deletions

View File

@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4.1.6
- name: Set Node.js 20.x - name: Set Node.js 20.x
uses: actions/setup-node@v4 uses: actions/setup-node@v4

View File

@ -39,7 +39,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v3 uses: github/codeql-action/init@v3

View File

@ -9,6 +9,6 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Check licenses name: Check licenses
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4.1.6
- run: npm ci - run: npm ci
- run: npm run licensed-check - run: npm run licensed-check

View File

@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-node@v4 - uses: actions/setup-node@v4
with: with:
node-version: 20.x node-version: 20.x
- uses: actions/checkout@v4 - uses: actions/checkout@v4.1.6
- run: npm ci - run: npm ci
- run: npm run build - run: npm run build
- run: npm run format-check - run: npm run format-check
@ -37,7 +37,7 @@ jobs:
steps: steps:
# Clone this repo # Clone this repo
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
# Basic checkout # Basic checkout
- name: Checkout basic - name: Checkout basic
@ -202,7 +202,7 @@ jobs:
steps: steps:
# Clone this repo # Clone this repo
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
# Basic checkout using git # Basic checkout using git
- name: Checkout basic - name: Checkout basic
@ -234,7 +234,7 @@ jobs:
steps: steps:
# Clone this repo # Clone this repo
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
# Basic checkout using git # Basic checkout using git
- name: Checkout basic - name: Checkout basic
@ -264,13 +264,13 @@ jobs:
steps: steps:
# Clone this repo # Clone this repo
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
with: with:
path: v4 path: localClone
# Basic checkout using git # Basic checkout using git
- name: Checkout basic - name: Checkout basic
uses: ./v4 uses: ./localClone
with: with:
ref: test-data/v2/basic ref: test-data/v2/basic
- name: Verify basic - name: Verify basic
@ -292,6 +292,6 @@ jobs:
# needed to make checkout post cleanup succeed # needed to make checkout post cleanup succeed
- name: Fix Checkout v4 - name: Fix Checkout v4
uses: actions/checkout@v4 uses: actions/checkout@v4.1.6
with: with:
path: v4 path: localClone

View File

@ -22,7 +22,7 @@ jobs:
# Note this update workflow can also be used as a rollback tool. # Note this update workflow can also be used as a rollback tool.
# For that reason, it's best to pin `actions/checkout` to a known, stable version # For that reason, it's best to pin `actions/checkout` to a known, stable version
# (typically, about two releases back). # (typically, about two releases back).
- uses: actions/checkout@v4 - uses: actions/checkout@v4.1.6
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Git config - name: Git config

View File

@ -1,5 +1,11 @@
# Changelog # Changelog
## v4.1.7
* Bump the minor-npm-dependencies group across 1 directory with 4 updates by @dependabot in https://github.com/actions/checkout/pull/1739
* Bump actions/checkout from 3 to 4 by @dependabot in https://github.com/actions/checkout/pull/1697
* Check out other refs/* by commit by @orhantoy in https://github.com/actions/checkout/pull/1774
* Pin actions/checkout's own workflows to a known, good, stable version. by @jww3 in https://github.com/actions/checkout/pull/1776
## v4.1.6 ## v4.1.6
* Check platform to set archive extension appropriately by @cory-miller in https://github.com/actions/checkout/pull/1732 * Check platform to set archive extension appropriately by @cory-miller in https://github.com/actions/checkout/pull/1732

View File

@ -251,7 +251,7 @@ Please refer to the [release page](https://github.com/actions/checkout/releases/
```yaml ```yaml
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha || github.ref }}
``` ```
## Checkout pull request on closed event ## Checkout pull request on closed event

View File

@ -67,6 +67,16 @@ describe('ref-helper tests', () => {
expect(checkoutInfo.startPoint).toBeFalsy() expect(checkoutInfo.startPoint).toBeFalsy()
}) })
it('getCheckoutInfo refs/', async () => {
const checkoutInfo = await refHelper.getCheckoutInfo(
git,
'refs/gh/queue/main/pr-123',
commit
)
expect(checkoutInfo.ref).toBe(commit)
expect(checkoutInfo.startPoint).toBeFalsy()
})
it('getCheckoutInfo unqualified branch only', async () => { it('getCheckoutInfo unqualified branch only', async () => {
git.branchExists = jest.fn(async (remote: boolean, pattern: string) => { git.branchExists = jest.fn(async (remote: boolean, pattern: string) => {
return true return true

6
dist/index.js vendored
View File

@ -2000,9 +2000,13 @@ function getCheckoutInfo(git, ref, commit) {
result.ref = `refs/remotes/pull/${branch}`; result.ref = `refs/remotes/pull/${branch}`;
} }
// refs/tags/ // refs/tags/
else if (upperRef.startsWith('REFS/')) { else if (upperRef.startsWith('REFS/TAGS/')) {
result.ref = ref; result.ref = ref;
} }
// refs/
else if (upperRef.startsWith('REFS/') && commit) {
result.ref = commit;
}
// Unqualified ref, check for a matching branch or tag // Unqualified ref, check for a matching branch or tag
else { else {
if (yield git.branchExists(true, `origin/${ref}`)) { if (yield git.branchExists(true, `origin/${ref}`)) {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "checkout", "name": "checkout",
"version": "4.1.6", "version": "4.1.7",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "checkout", "name": "checkout",
"version": "4.1.6", "version": "4.1.7",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.1", "@actions/core": "^1.10.1",

View File

@ -1,6 +1,6 @@
{ {
"name": "checkout", "name": "checkout",
"version": "4.1.6", "version": "4.1.7",
"description": "checkout action", "description": "checkout action",
"main": "lib/main.js", "main": "lib/main.js",
"scripts": { "scripts": {

View File

@ -42,9 +42,13 @@ export async function getCheckoutInfo(
result.ref = `refs/remotes/pull/${branch}` result.ref = `refs/remotes/pull/${branch}`
} }
// refs/tags/ // refs/tags/
else if (upperRef.startsWith('REFS/')) { else if (upperRef.startsWith('REFS/TAGS/')) {
result.ref = ref result.ref = ref
} }
// refs/
else if (upperRef.startsWith('REFS/') && commit) {
result.ref = commit
}
// Unqualified ref, check for a matching branch or tag // Unqualified ref, check for a matching branch or tag
else { else {
if (await git.branchExists(true, `origin/${ref}`)) { if (await git.branchExists(true, `origin/${ref}`)) {