mirror of
https://github.com/peter-evans/create-pull-request.git
synced 2026-12-05 05:02:57 +00:00
Compare commits
49
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41cf0afe47 | ||
|
|
b457f7bfef | ||
|
|
3ffccacd46 | ||
|
|
77d56500d9 | ||
|
|
15733dbdfe | ||
|
|
3afad46a91 | ||
|
|
aee70bea9c | ||
|
|
86c87cfdd8 | ||
|
|
bd09a93810 | ||
|
|
59910dc448 | ||
|
|
753b4376e5 | ||
|
|
abadea5d94 | ||
|
|
11e8dc7c9c | ||
|
|
c9f8b51aaa | ||
|
|
1a3c7ab17d | ||
|
|
762a4a5ab1 | ||
|
|
b99c9ae23b | ||
|
|
11fa467881 | ||
|
|
92f6f0bc90 | ||
|
|
7ec5aae3c9 | ||
|
|
c66b8cb005 | ||
|
|
653ba8b281 | ||
|
|
6fff569d74 | ||
|
|
a78ae501dd | ||
|
|
de36595094 | ||
|
|
5f42108561 | ||
|
|
8c5aeef7f4 | ||
|
|
8b4b9968cb | ||
|
|
aa523f9db6 | ||
|
|
d8c15c739f | ||
|
|
eec7ab75b2 | ||
|
|
5f6978faf0 | ||
|
|
d32e88dac7 | ||
|
|
8170bccad1 | ||
|
|
00418193b4 | ||
|
|
b993918c85 | ||
|
|
36d7c8468b | ||
|
|
a45d1fb447 | ||
|
|
3499eb6183 | ||
|
|
3f3b473b8c | ||
|
|
6699836a21 | ||
|
|
c0f553fe54 | ||
|
|
70001242bf | ||
|
|
34aa40e9cf | ||
|
|
641099ddca | ||
|
|
2271f1ddcf | ||
|
|
437c31a11d | ||
|
|
0979079bc2 | ||
|
|
5b751cdf40 |
No files matched your search
@@ -5,6 +5,8 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: "monthly"
|
interval: "monthly"
|
||||||
day: "tuesday"
|
day: "tuesday"
|
||||||
|
cooldown:
|
||||||
|
default-days: 3
|
||||||
labels:
|
labels:
|
||||||
- "dependencies"
|
- "dependencies"
|
||||||
groups:
|
groups:
|
||||||
@@ -17,6 +19,8 @@ updates:
|
|||||||
schedule:
|
schedule:
|
||||||
interval: "monthly"
|
interval: "monthly"
|
||||||
day: "tuesday"
|
day: "tuesday"
|
||||||
|
cooldown:
|
||||||
|
default-days: 3
|
||||||
ignore:
|
ignore:
|
||||||
- dependency-name: "*"
|
- dependency-name: "*"
|
||||||
update-types: ["version-update:semver-major"]
|
update-types: ["version-update:semver-major"]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: github.actor == 'dependabot[bot]'
|
if: github.actor == 'dependabot[bot]'
|
||||||
steps:
|
steps:
|
||||||
- uses: peter-evans/enable-pull-request-automerge@v3
|
- uses: peter-evans/enable-pull-request-automerge@a660677d5469627102a1c1e11409dd063606628d # v3.0.0
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
pull-request-number: ${{ github.event.pull_request.number }}
|
pull-request-number: ${{ github.event.pull_request.number }}
|
||||||
|
|||||||
+13
-13
@@ -19,8 +19,8 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
|
||||||
with:
|
with:
|
||||||
node-version-file: package.json
|
node-version-file: package.json
|
||||||
cache: npm
|
cache: npm
|
||||||
@@ -29,11 +29,11 @@ jobs:
|
|||||||
- run: npm run format-check
|
- run: npm run format-check
|
||||||
- run: npm run lint
|
- run: npm run lint
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
- uses: actions/upload-artifact@v5
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- uses: actions/upload-artifact@v5
|
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
||||||
with:
|
with:
|
||||||
name: action.yml
|
name: action.yml
|
||||||
path: action.yml
|
path: action.yml
|
||||||
@@ -46,16 +46,16 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
target: [built, committed]
|
target: [built, committed]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
ref: main
|
ref: main
|
||||||
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
uses: actions/download-artifact@v6
|
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: action.yml
|
name: action.yml
|
||||||
path: .
|
path: .
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
branch: ci-test-${{ matrix.target }}-${{ github.sha }}
|
branch: ci-test-${{ matrix.target }}-${{ github.sha }}
|
||||||
|
|
||||||
- name: Close Pull
|
- name: Close Pull
|
||||||
uses: peter-evans/close-pull@v3
|
uses: peter-evans/close-pull@a192af8d70f2d49c49643134605c3b73d4f80fae # v3.0.1
|
||||||
with:
|
with:
|
||||||
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
||||||
comment: '[CI] test ${{ matrix.target }}'
|
comment: '[CI] test ${{ matrix.target }}'
|
||||||
@@ -92,7 +92,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Find Comment
|
- name: Find Comment
|
||||||
uses: peter-evans/find-comment@v4
|
uses: peter-evans/find-comment@b30e6a3c0ed37e7c023ccd3f1db5c6c0b0c23aad # v4.0.0
|
||||||
id: fc
|
id: fc
|
||||||
with:
|
with:
|
||||||
issue-number: ${{ github.event.number }}
|
issue-number: ${{ github.event.number }}
|
||||||
@@ -101,7 +101,7 @@ jobs:
|
|||||||
|
|
||||||
- if: steps.fc.outputs.comment-id == ''
|
- if: steps.fc.outputs.comment-id == ''
|
||||||
name: Create comment
|
name: Create comment
|
||||||
uses: peter-evans/create-or-update-comment@v5
|
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
|
||||||
with:
|
with:
|
||||||
issue-number: ${{ github.event.number }}
|
issue-number: ${{ github.event.number }}
|
||||||
body: |
|
body: |
|
||||||
@@ -118,13 +118,13 @@ jobs:
|
|||||||
needs: [test]
|
needs: [test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
- uses: actions/download-artifact@v6
|
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@3ffccacd46053766916f087ce41d627c0b8cf2d1 # v8.1.3
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
commit-message: 'build: update distribution'
|
commit-message: 'build: update distribution'
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ jobs:
|
|||||||
createPullRequest:
|
createPullRequest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
|
|
||||||
- name: Make changes to pull request
|
- name: Make changes to pull request
|
||||||
run: date +%s > report.txt
|
run: date +%s > report.txt
|
||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
||||||
|
|
||||||
- name: Add reaction
|
- name: Add reaction
|
||||||
uses: peter-evans/create-or-update-comment@v5
|
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
|
||||||
with:
|
with:
|
||||||
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
|
||||||
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
|
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Slash Command Dispatch
|
- name: Slash Command Dispatch
|
||||||
uses: peter-evans/slash-command-dispatch@v5
|
uses: peter-evans/slash-command-dispatch@9bdcd7914ec1b75590b790b844aa3b8eee7c683a # v5.0.2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
config: >
|
config: >
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
tag:
|
tag:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v6
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
@@ -27,6 +27,13 @@ jobs:
|
|||||||
git config user.name actions-bot
|
git config user.name actions-bot
|
||||||
git config user.email actions-bot@users.noreply.github.com
|
git config user.email actions-bot@users.noreply.github.com
|
||||||
- name: Tag new target
|
- name: Tag new target
|
||||||
run: git tag -f ${{ github.event.inputs.main_version }} ${{ github.event.inputs.target }}
|
run: |
|
||||||
|
sha=$(git rev-parse --verify --end-of-options "${INPUT_TARGET}^{commit}")
|
||||||
|
git tag -f "${INPUT_MAIN_VERSION}" "${sha}"
|
||||||
|
env:
|
||||||
|
INPUT_MAIN_VERSION: ${{ github.event.inputs.main_version }}
|
||||||
|
INPUT_TARGET: ${{ github.event.inputs.target }}
|
||||||
- name: Push new tag
|
- name: Push new tag
|
||||||
run: git push origin ${{ github.event.inputs.main_version }} --force
|
run: git push origin "${INPUT_MAIN_VERSION}" --force
|
||||||
|
env:
|
||||||
|
INPUT_MAIN_VERSION: ${{ github.event.inputs.main_version }}
|
||||||
@@ -32,10 +32,10 @@ Create Pull Request action will:
|
|||||||
# Make changes to pull request here
|
# Make changes to pull request here
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v7.x.x`
|
You can also pin to a [specific release](https://github.com/peter-evans/create-pull-request/releases) version in the format `@v8.x.x`
|
||||||
|
|
||||||
### Workflow permissions
|
### Workflow permissions
|
||||||
|
|
||||||
@@ -131,7 +131,7 @@ If you want branches to be deleted immediately on merge then you should use GitH
|
|||||||
For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable.
|
For self-hosted runners behind a corporate proxy set the `https_proxy` environment variable.
|
||||||
```yml
|
```yml
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
env:
|
env:
|
||||||
https_proxy: http://<proxy_address>:<port>
|
https_proxy: http://<proxy_address>:<port>
|
||||||
```
|
```
|
||||||
@@ -153,7 +153,7 @@ Note that in order to read the step outputs the action step must have an id.
|
|||||||
```yml
|
```yml
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr
|
id: cpr
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
- name: Check outputs
|
- name: Check outputs
|
||||||
if: ${{ steps.cpr.outputs.pull-request-number }}
|
if: ${{ steps.cpr.outputs.pull-request-number }}
|
||||||
run: |
|
run: |
|
||||||
@@ -216,7 +216,7 @@ File changes that do not match one of the paths will be stashed and restored aft
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
with:
|
with:
|
||||||
add-paths: |
|
add-paths: |
|
||||||
*.java
|
*.java
|
||||||
@@ -230,7 +230,7 @@ Note that the repository must be checked out on a branch with a remote, it won't
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- name: Create commits
|
- name: Create commits
|
||||||
run: |
|
run: |
|
||||||
git config user.name 'Peter Evans'
|
git config user.name 'Peter Evans'
|
||||||
@@ -243,7 +243,7 @@ Note that the repository must be checked out on a branch with a remote, it won't
|
|||||||
- name: Uncommitted change
|
- name: Uncommitted change
|
||||||
run: date +%s > report.txt
|
run: date +%s > report.txt
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
```
|
```
|
||||||
|
|
||||||
### Auto-merge
|
### Auto-merge
|
||||||
@@ -263,14 +263,14 @@ jobs:
|
|||||||
createPullRequest:
|
createPullRequest:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Make changes to pull request
|
- name: Make changes to pull request
|
||||||
run: date +%s > report.txt
|
run: date +%s > report.txt
|
||||||
|
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
id: cpr
|
id: cpr
|
||||||
uses: peter-evans/create-pull-request@v7
|
uses: peter-evans/create-pull-request@v8
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.PAT }}
|
token: ${{ secrets.PAT }}
|
||||||
commit-message: Update report
|
commit-message: Update report
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import {
|
|||||||
getWorkingBaseAndType,
|
getWorkingBaseAndType,
|
||||||
buildBranchCommits
|
buildBranchCommits
|
||||||
} from '../lib/create-or-update-branch'
|
} from '../lib/create-or-update-branch'
|
||||||
|
import {randomUUID} from 'crypto'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import {GitCommandManager} from '../lib/git-command-manager'
|
import {GitCommandManager} from '../lib/git-command-manager'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
|
||||||
|
|
||||||
const REPO_PATH = '/git/local/repos/test-base'
|
const REPO_PATH = '/git/local/repos/test-base'
|
||||||
const REMOTE_NAME = 'origin'
|
const REMOTE_NAME = 'origin'
|
||||||
@@ -31,7 +31,7 @@ const ADD_PATHS_MULTI = ['a', 'b']
|
|||||||
const ADD_PATHS_WILDCARD = ['a/*.txt', 'b/*.txt']
|
const ADD_PATHS_WILDCARD = ['a/*.txt', 'b/*.txt']
|
||||||
|
|
||||||
async function createFile(filename: string, content?: string): Promise<string> {
|
async function createFile(filename: string, content?: string): Promise<string> {
|
||||||
const _content = content ? content : uuidv4()
|
const _content = content ? content : randomUUID()
|
||||||
const filepath = path.join(REPO_PATH, filename)
|
const filepath = path.join(REPO_PATH, filename)
|
||||||
await fs.promises.mkdir(path.dirname(filepath), {recursive: true})
|
await fs.promises.mkdir(path.dirname(filepath), {recursive: true})
|
||||||
await fs.promises.writeFile(filepath, _content, {encoding: 'utf8'})
|
await fs.promises.writeFile(filepath, _content, {encoding: 'utf8'})
|
||||||
@@ -82,7 +82,7 @@ async function createCommits(
|
|||||||
} else {
|
} else {
|
||||||
result.changes = await createChanges()
|
result.changes = await createChanges()
|
||||||
}
|
}
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
await git.exec(['add', '-A'])
|
await git.exec(['add', '-A'])
|
||||||
await git.commit(['-m', commitMessage])
|
await git.commit(['-m', commitMessage])
|
||||||
result.commitMsgs.unshift(commitMessage)
|
result.commitMsgs.unshift(commitMessage)
|
||||||
@@ -313,7 +313,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('tests no changes resulting in no new branch being created', async () => {
|
it('tests no changes resulting in no new branch being created', async () => {
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -330,7 +330,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with a tracked file change', async () => {
|
it('tests create and update with a tracked file change', async () => {
|
||||||
// Create a tracked file change
|
// Create a tracked file change
|
||||||
const trackedContent = await createFile(TRACKED_FILE)
|
const trackedContent = await createFile(TRACKED_FILE)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -359,7 +359,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create a tracked file change
|
// Create a tracked file change
|
||||||
const _trackedContent = await createFile(TRACKED_FILE)
|
const _trackedContent = await createFile(TRACKED_FILE)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -381,7 +381,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with an untracked file change', async () => {
|
it('tests create and update with an untracked file change', async () => {
|
||||||
// Create an untracked file change
|
// Create an untracked file change
|
||||||
const untrackedContent = await createFile(UNTRACKED_FILE)
|
const untrackedContent = await createFile(UNTRACKED_FILE)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -410,7 +410,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create an untracked file change
|
// Create an untracked file change
|
||||||
const _untrackedContent = await createFile(UNTRACKED_FILE)
|
const _untrackedContent = await createFile(UNTRACKED_FILE)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -434,7 +434,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -464,7 +464,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create identical tracked and untracked file changes
|
// Create identical tracked and untracked file changes
|
||||||
await createChanges(changes.tracked, changes.untracked)
|
await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -486,7 +486,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with commits on the base inbetween', async () => {
|
it('tests create and update with commits on the base inbetween', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -524,7 +524,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -556,7 +556,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -585,7 +585,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
await beforeTest()
|
await beforeTest()
|
||||||
|
|
||||||
// Running with no update effectively reverts the branch back to match the base
|
// Running with no update effectively reverts the branch back to match the base
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -607,7 +607,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -648,7 +648,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
commits.changes.tracked,
|
commits.changes.tracked,
|
||||||
commits.changes.untracked
|
commits.changes.untracked
|
||||||
)
|
)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -673,7 +673,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -703,7 +703,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create a commit on the base with a partial merge of the changes
|
// Create a commit on the base with a partial merge of the changes
|
||||||
await createFile(TRACKED_FILE, changes.tracked)
|
await createFile(TRACKED_FILE, changes.tracked)
|
||||||
const baseCommitMessage = uuidv4()
|
const baseCommitMessage = randomUUID()
|
||||||
await git.exec(['add', '-A'])
|
await git.exec(['add', '-A'])
|
||||||
await git.commit(['-m', baseCommitMessage])
|
await git.commit(['-m', baseCommitMessage])
|
||||||
await git.push([
|
await git.push([
|
||||||
@@ -714,7 +714,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes
|
// Create the same tracked and untracked file changes
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -746,7 +746,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -790,7 +790,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes (no change on update)
|
// Create the same tracked and untracked file changes (no change on update)
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -816,7 +816,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -845,7 +845,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
await beforeTest()
|
await beforeTest()
|
||||||
|
|
||||||
// Force push the base branch to a different commit
|
// Force push the base branch to a different commit
|
||||||
const amendedCommitMessage = uuidv4()
|
const amendedCommitMessage = randomUUID()
|
||||||
await git.commit(['--amend', '-m', amendedCommitMessage])
|
await git.commit(['--amend', '-m', amendedCommitMessage])
|
||||||
await git.push([
|
await git.push([
|
||||||
'--force',
|
'--force',
|
||||||
@@ -855,7 +855,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes (no change on update)
|
// Create the same tracked and untracked file changes (no change on update)
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -878,7 +878,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with commits on the working base (during the workflow)', async () => {
|
it('tests create and update with commits on the working base (during the workflow)', async () => {
|
||||||
// Create commits on the working base
|
// Create commits on the working base
|
||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -910,7 +910,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create commits on the working base
|
// Create commits on the working base
|
||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -937,7 +937,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -973,7 +973,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1002,7 +1002,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1046,7 +1046,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1074,7 +1074,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update using a different remote from the base', async () => {
|
it('tests create and update using a different remote from the base', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1104,7 +1104,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1127,7 +1127,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with signoff on commit', async () => {
|
it('tests create and update with signoff on commit', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1164,7 +1164,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1194,7 +1194,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with multiple add-paths', async () => {
|
it('tests create and update with multiple add-paths', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1224,7 +1224,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1247,7 +1247,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create and update with wildcard add-paths', async () => {
|
it('tests create and update with wildcard add-paths', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1277,7 +1277,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1300,7 +1300,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
it('tests create with add-paths resolving to no changes when other changes exist', async () => {
|
it('tests create with add-paths resolving to no changes when other changes exist', async () => {
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
await createChanges()
|
await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1321,7 +1321,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const resultA = await createOrUpdateBranch(
|
const resultA = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1365,7 +1365,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
// Set the working base to a branch that is not the pull request base
|
// Set the working base to a branch that is not the pull request base
|
||||||
await git.checkout(NOT_BASE_BRANCH)
|
await git.checkout(NOT_BASE_BRANCH)
|
||||||
|
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1386,7 +1386,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create a tracked file change
|
// Create a tracked file change
|
||||||
const trackedContent = await createFile(TRACKED_FILE)
|
const trackedContent = await createFile(TRACKED_FILE)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1418,7 +1418,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create a tracked file change
|
// Create a tracked file change
|
||||||
const _trackedContent = await createFile(TRACKED_FILE)
|
const _trackedContent = await createFile(TRACKED_FILE)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1443,7 +1443,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create an untracked file change
|
// Create an untracked file change
|
||||||
const untrackedContent = await createFile(UNTRACKED_FILE)
|
const untrackedContent = await createFile(UNTRACKED_FILE)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1475,7 +1475,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create an untracked file change
|
// Create an untracked file change
|
||||||
const _untrackedContent = await createFile(UNTRACKED_FILE)
|
const _untrackedContent = await createFile(UNTRACKED_FILE)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1502,7 +1502,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1535,7 +1535,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create identical tracked and untracked file changes
|
// Create identical tracked and untracked file changes
|
||||||
await createChanges(changes.tracked, changes.untracked)
|
await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1560,7 +1560,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1601,7 +1601,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1635,7 +1635,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1667,7 +1667,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
await git.checkout(NOT_BASE_BRANCH)
|
await git.checkout(NOT_BASE_BRANCH)
|
||||||
|
|
||||||
// Running with no update effectively reverts the branch back to match the base
|
// Running with no update effectively reverts the branch back to match the base
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1694,7 +1694,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1738,7 +1738,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
commits.changes.tracked,
|
commits.changes.tracked,
|
||||||
commits.changes.untracked
|
commits.changes.untracked
|
||||||
)
|
)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1768,7 +1768,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1798,7 +1798,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create a commit on the base with a partial merge of the changes
|
// Create a commit on the base with a partial merge of the changes
|
||||||
await createFile(TRACKED_FILE, changes.tracked)
|
await createFile(TRACKED_FILE, changes.tracked)
|
||||||
const baseCommitMessage = uuidv4()
|
const baseCommitMessage = randomUUID()
|
||||||
await git.exec(['add', '-A'])
|
await git.exec(['add', '-A'])
|
||||||
await git.commit(['-m', baseCommitMessage])
|
await git.commit(['-m', baseCommitMessage])
|
||||||
await git.push([
|
await git.push([
|
||||||
@@ -1812,7 +1812,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes
|
// Create the same tracked and untracked file changes
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1846,7 +1846,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1893,7 +1893,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes (no change on update)
|
// Create the same tracked and untracked file changes (no change on update)
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1924,7 +1924,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -1953,7 +1953,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
await beforeTest()
|
await beforeTest()
|
||||||
|
|
||||||
// Force push the base branch to a different commit
|
// Force push the base branch to a different commit
|
||||||
const amendedCommitMessage = uuidv4()
|
const amendedCommitMessage = randomUUID()
|
||||||
await git.commit(['--amend', '-m', amendedCommitMessage])
|
await git.commit(['--amend', '-m', amendedCommitMessage])
|
||||||
await git.push([
|
await git.push([
|
||||||
'--force',
|
'--force',
|
||||||
@@ -1966,7 +1966,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create the same tracked and untracked file changes (no change on update)
|
// Create the same tracked and untracked file changes (no change on update)
|
||||||
const _changes = await createChanges(changes.tracked, changes.untracked)
|
const _changes = await createChanges(changes.tracked, changes.untracked)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -1992,7 +1992,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create commits on the working base
|
// Create commits on the working base
|
||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2027,7 +2027,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create commits on the working base
|
// Create commits on the working base
|
||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2057,7 +2057,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2096,7 +2096,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2128,7 +2128,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2175,7 +2175,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
const _commits = await createCommits(git)
|
const _commits = await createCommits(git)
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2205,7 +2205,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2238,7 +2238,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2268,7 +2268,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2302,7 +2302,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2329,7 +2329,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2371,7 +2371,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const _changes = await createChanges()
|
const _changes = await createChanges()
|
||||||
const _commitMessage = uuidv4()
|
const _commitMessage = randomUUID()
|
||||||
const _result = await createOrUpdateBranch(
|
const _result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
_commitMessage,
|
_commitMessage,
|
||||||
@@ -2403,7 +2403,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create commits on the working base
|
// Create commits on the working base
|
||||||
const commits = await createCommits(git)
|
const commits = await createCommits(git)
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const result = await createOrUpdateBranch(
|
const result = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
@@ -2428,7 +2428,7 @@ describe('create-or-update-branch tests', () => {
|
|||||||
|
|
||||||
// Create tracked and untracked file changes
|
// Create tracked and untracked file changes
|
||||||
const changes = await createChanges()
|
const changes = await createChanges()
|
||||||
const commitMessage = uuidv4()
|
const commitMessage = randomUUID()
|
||||||
const resultA = await createOrUpdateBranch(
|
const resultA = await createOrUpdateBranch(
|
||||||
git,
|
git,
|
||||||
commitMessage,
|
commitMessage,
|
||||||
|
|||||||
@@ -0,0 +1,182 @@
|
|||||||
|
import {GitHubHelper} from '../lib/github-helper'
|
||||||
|
import {Commit, GitCommandManager} from '../lib/git-command-manager'
|
||||||
|
|
||||||
|
const mockOctokit = {
|
||||||
|
rest: {
|
||||||
|
git: {
|
||||||
|
createBlob: jest.fn(),
|
||||||
|
createTree: jest.fn(),
|
||||||
|
createCommit: jest.fn(),
|
||||||
|
createRef: jest.fn(),
|
||||||
|
getRef: jest.fn(),
|
||||||
|
updateRef: jest.fn()
|
||||||
|
},
|
||||||
|
repos: {
|
||||||
|
getBranch: jest.fn()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
jest.mock('../lib/octokit-client', () => ({
|
||||||
|
Octokit: jest.fn(() => mockOctokit),
|
||||||
|
throttleOptions: {},
|
||||||
|
retryOptions: {}
|
||||||
|
}))
|
||||||
|
jest.mock('@octokit/request-error', () => ({RequestError: class {}}))
|
||||||
|
jest.mock('p-limit', () => () => (fn: () => unknown) => fn())
|
||||||
|
|
||||||
|
const NULL_SHA = '0000000000000000000000000000000000000000'
|
||||||
|
|
||||||
|
function makeCommit(changes: Commit['changes']): Commit {
|
||||||
|
return {
|
||||||
|
sha: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
|
||||||
|
tree: 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
|
||||||
|
parents: ['cccccccccccccccccccccccccccccccccccccccc'],
|
||||||
|
signed: false,
|
||||||
|
subject: 'Test commit',
|
||||||
|
body: '',
|
||||||
|
changes,
|
||||||
|
unparsedChanges: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('github-helper unit tests', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('pushSignedCommits deletes a removed submodule instead of pointing it at the null sha', async () => {
|
||||||
|
const {git: gitApi} = mockOctokit.rest
|
||||||
|
gitApi.createBlob.mockResolvedValue({
|
||||||
|
data: {sha: 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'}
|
||||||
|
})
|
||||||
|
gitApi.createTree.mockResolvedValue({
|
||||||
|
data: {sha: 'dddddddddddddddddddddddddddddddddddddddd'}
|
||||||
|
})
|
||||||
|
gitApi.createCommit.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
sha: 'ffffffffffffffffffffffffffffffffffffffff',
|
||||||
|
tree: {sha: 'dddddddddddddddddddddddddddddddddddddddd'},
|
||||||
|
verification: {verified: true, reason: 'valid'}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
gitApi.createRef.mockResolvedValue({})
|
||||||
|
gitApi.getRef.mockRejectedValue(new Error('Not Found'))
|
||||||
|
const git = {
|
||||||
|
showFileAtRefBase64: jest.fn().mockResolvedValue('Y29udGVudA==')
|
||||||
|
}
|
||||||
|
|
||||||
|
const helper = new GitHubHelper('github.com', 'token')
|
||||||
|
|
||||||
|
const baseCommit = makeCommit([])
|
||||||
|
const commit = makeCommit([
|
||||||
|
{
|
||||||
|
mode: '160000',
|
||||||
|
dstSha: NULL_SHA,
|
||||||
|
status: 'D',
|
||||||
|
path: 'submodules/removed'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: '160000',
|
||||||
|
dstSha: '1111111111111111111111111111111111111111',
|
||||||
|
status: 'M',
|
||||||
|
path: 'submodules/updated'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mode: '100644',
|
||||||
|
dstSha: '2222222222222222222222222222222222222222',
|
||||||
|
status: 'M',
|
||||||
|
path: '.gitmodules'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
await helper.pushSignedCommits(
|
||||||
|
git as unknown as GitCommandManager,
|
||||||
|
[commit],
|
||||||
|
baseCommit,
|
||||||
|
'/repo',
|
||||||
|
'owner/repo',
|
||||||
|
'branch'
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(gitApi.createTree).toHaveBeenCalledTimes(1)
|
||||||
|
const {tree} = gitApi.createTree.mock.calls[0][0]
|
||||||
|
expect(tree).toEqual([
|
||||||
|
{
|
||||||
|
path: 'submodules/removed',
|
||||||
|
mode: '160000',
|
||||||
|
sha: null,
|
||||||
|
type: 'commit'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: 'submodules/updated',
|
||||||
|
mode: '160000',
|
||||||
|
sha: '1111111111111111111111111111111111111111',
|
||||||
|
type: 'commit'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '.gitmodules',
|
||||||
|
mode: '100644',
|
||||||
|
sha: 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee',
|
||||||
|
type: 'blob'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
test('pushSignedCommits creates the ref when the branch name only resolves via a branch rename redirect', async () => {
|
||||||
|
const {git: gitApi, repos: reposApi} = mockOctokit.rest
|
||||||
|
// The branches API follows rename redirects and returns the renamed branch
|
||||||
|
reposApi.getBranch.mockResolvedValue({data: {name: 'renamed-branch'}})
|
||||||
|
gitApi.getRef.mockRejectedValue(new Error('Not Found'))
|
||||||
|
gitApi.createRef.mockResolvedValue({})
|
||||||
|
|
||||||
|
const helper = new GitHubHelper('github.com', 'token')
|
||||||
|
const baseCommit = makeCommit([])
|
||||||
|
await helper.pushSignedCommits(
|
||||||
|
{} as GitCommandManager,
|
||||||
|
[],
|
||||||
|
baseCommit,
|
||||||
|
'/repo',
|
||||||
|
'owner/repo',
|
||||||
|
'branch'
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(gitApi.getRef).toHaveBeenCalledWith({
|
||||||
|
owner: 'owner',
|
||||||
|
repo: 'repo',
|
||||||
|
ref: 'heads/branch'
|
||||||
|
})
|
||||||
|
expect(gitApi.createRef).toHaveBeenCalledWith({
|
||||||
|
owner: 'owner',
|
||||||
|
repo: 'repo',
|
||||||
|
sha: baseCommit.sha,
|
||||||
|
ref: 'refs/heads/branch'
|
||||||
|
})
|
||||||
|
expect(gitApi.updateRef).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('pushSignedCommits updates the ref when the branch exists', async () => {
|
||||||
|
const {git: gitApi} = mockOctokit.rest
|
||||||
|
gitApi.getRef.mockResolvedValue({data: {ref: 'refs/heads/branch'}})
|
||||||
|
gitApi.updateRef.mockResolvedValue({})
|
||||||
|
|
||||||
|
const helper = new GitHubHelper('github.com', 'token')
|
||||||
|
const baseCommit = makeCommit([])
|
||||||
|
await helper.pushSignedCommits(
|
||||||
|
{} as GitCommandManager,
|
||||||
|
[],
|
||||||
|
baseCommit,
|
||||||
|
'/repo',
|
||||||
|
'owner/repo',
|
||||||
|
'branch'
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(gitApi.updateRef).toHaveBeenCalledWith({
|
||||||
|
owner: 'owner',
|
||||||
|
repo: 'repo',
|
||||||
|
sha: baseCommit.sha,
|
||||||
|
ref: 'heads/branch',
|
||||||
|
force: true
|
||||||
|
})
|
||||||
|
expect(gitApi.createRef).not.toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -10,7 +10,7 @@ if [[ "$(docker images -q $IMAGE 2> /dev/null)" == "" || $ARG1 == "build" ]]; th
|
|||||||
cat > Dockerfile << EOF
|
cat > Dockerfile << EOF
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
RUN apk --no-cache add git git-daemon
|
RUN apk --no-cache add git git-daemon
|
||||||
RUN npm install jest jest-environment-jsdom --global
|
RUN npm install jest@30 jest-environment-jsdom@30 --global
|
||||||
WORKDIR /cpr
|
WORKDIR /cpr
|
||||||
COPY __test__/entrypoint.sh /entrypoint.sh
|
COPY __test__/entrypoint.sh /entrypoint.sh
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
|||||||
@@ -118,3 +118,71 @@ describe('utils tests', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('retryWithBackoff', () => {
|
||||||
|
const makeConsistencyError = () => {
|
||||||
|
const error = new Error(
|
||||||
|
'Validation Failed: "Could not resolve to a node with the global id of \'PR_abc123\'."'
|
||||||
|
)
|
||||||
|
;(error as any).status = 422
|
||||||
|
return error
|
||||||
|
}
|
||||||
|
|
||||||
|
const shouldRetry = (e: unknown): boolean =>
|
||||||
|
e instanceof Error &&
|
||||||
|
(e as any).status === 422 &&
|
||||||
|
e.message.includes('Could not resolve to a node')
|
||||||
|
|
||||||
|
test('succeeds on first attempt without retrying', async () => {
|
||||||
|
const fn = jest.fn().mockResolvedValue('success')
|
||||||
|
const result = await utils.retryWithBackoff(fn, shouldRetry, 2, 1)
|
||||||
|
expect(result).toBe('success')
|
||||||
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('retries on eventual consistency 422 and succeeds', async () => {
|
||||||
|
const fn = jest
|
||||||
|
.fn()
|
||||||
|
.mockRejectedValueOnce(makeConsistencyError())
|
||||||
|
.mockResolvedValue('success')
|
||||||
|
const result = await utils.retryWithBackoff(fn, shouldRetry, 2, 1)
|
||||||
|
expect(result).toBe('success')
|
||||||
|
expect(fn).toHaveBeenCalledTimes(2)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('exhausts retries on persistent 422 and throws', async () => {
|
||||||
|
const fn = jest.fn().mockRejectedValue(makeConsistencyError())
|
||||||
|
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
|
||||||
|
'Could not resolve to a node'
|
||||||
|
)
|
||||||
|
expect(fn).toHaveBeenCalledTimes(3) // 1 initial + 2 retries
|
||||||
|
})
|
||||||
|
|
||||||
|
test('does not retry on non-422 errors', async () => {
|
||||||
|
const error = new Error('Forbidden')
|
||||||
|
;(error as any).status = 403
|
||||||
|
const fn = jest.fn().mockRejectedValue(error)
|
||||||
|
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
|
||||||
|
'Forbidden'
|
||||||
|
)
|
||||||
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('does not retry on 422 without the consistency error message', async () => {
|
||||||
|
const error = new Error('Validation Failed: invalid label')
|
||||||
|
;(error as any).status = 422
|
||||||
|
const fn = jest.fn().mockRejectedValue(error)
|
||||||
|
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
|
||||||
|
'Validation Failed: invalid label'
|
||||||
|
)
|
||||||
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
|
||||||
|
test('does not retry on plain Error objects', async () => {
|
||||||
|
const fn = jest.fn().mockRejectedValue(new Error('Something broke'))
|
||||||
|
await expect(utils.retryWithBackoff(fn, shouldRetry, 2, 1)).rejects.toThrow(
|
||||||
|
'Something broke'
|
||||||
|
)
|
||||||
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
Vendored
+237
-747
File diff suppressed because it is too large.
Load diff
+1
-1
@@ -3,7 +3,7 @@ module.exports = {
|
|||||||
moduleFileExtensions: ['js', 'ts'],
|
moduleFileExtensions: ['js', 'ts'],
|
||||||
testEnvironment: 'node',
|
testEnvironment: 'node',
|
||||||
testMatch: ['**/*.test.ts'],
|
testMatch: ['**/*.test.ts'],
|
||||||
testRunner: 'jest-circus/runner',
|
|
||||||
transform: {
|
transform: {
|
||||||
'^.+\\.ts$': 'ts-jest'
|
'^.+\\.ts$': 'ts-jest'
|
||||||
},
|
},
|
||||||
|
|||||||
Generated
+2885
-1643
File diff suppressed because it is too large.
Load diff
+12
-12
@@ -37,30 +37,30 @@
|
|||||||
"@octokit/core": "^6.1.6",
|
"@octokit/core": "^6.1.6",
|
||||||
"@octokit/plugin-paginate-rest": "^11.6.0",
|
"@octokit/plugin-paginate-rest": "^11.6.0",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^13.5.0",
|
"@octokit/plugin-rest-endpoint-methods": "^13.5.0",
|
||||||
|
"@octokit/plugin-retry": "^7.2.1",
|
||||||
"@octokit/plugin-throttling": "^9.6.1",
|
"@octokit/plugin-throttling": "^9.6.1",
|
||||||
|
"@octokit/request-error": "^6.1.8",
|
||||||
"node-fetch-native": "^1.6.7",
|
"node-fetch-native": "^1.6.7",
|
||||||
"p-limit": "^6.2.0",
|
"p-limit": "^6.2.0"
|
||||||
"uuid": "^9.0.1"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.14",
|
"@types/jest": "^30.0.0",
|
||||||
"@types/node": "^18.19.130",
|
"@types/node": "^18.19.130",
|
||||||
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.4",
|
"@vercel/ncc": "^0.45.0",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-import-resolver-typescript": "^3.10.1",
|
"eslint-import-resolver-typescript": "^3.10.1",
|
||||||
"eslint-plugin-github": "^4.10.2",
|
"eslint-plugin-github": "^4.10.2",
|
||||||
"eslint-plugin-import": "^2.32.0",
|
"eslint-plugin-import": "^2.32.0",
|
||||||
"eslint-plugin-jest": "^27.9.0",
|
"eslint-plugin-jest": "^27.9.0",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.7",
|
||||||
"jest": "^29.7.0",
|
"jest": "^30.5.2",
|
||||||
"jest-circus": "^29.7.0",
|
"jest-environment-jsdom": "^30.5.2",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"js-yaml": "^5.5.0",
|
||||||
"js-yaml": "^4.1.1",
|
"prettier": "^3.9.10",
|
||||||
"prettier": "^3.7.3",
|
"ts-jest": "^29.4.15",
|
||||||
"ts-jest": "^29.4.5",
|
|
||||||
"typescript": "^5.9.3",
|
"typescript": "^5.9.3",
|
||||||
"undici": "^6.22.0"
|
"undici": "^6.29.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {randomUUID} from 'crypto'
|
||||||
import {GitCommandManager, Commit} from './git-command-manager'
|
import {GitCommandManager, Commit} from './git-command-manager'
|
||||||
import {v4 as uuidv4} from 'uuid'
|
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
|
||||||
const CHERRYPICK_EMPTY =
|
const CHERRYPICK_EMPTY =
|
||||||
@@ -189,7 +189,7 @@ export async function createOrUpdateBranch(
|
|||||||
const baseRemote = 'origin'
|
const baseRemote = 'origin'
|
||||||
|
|
||||||
// Save the working base changes to a temporary branch
|
// Save the working base changes to a temporary branch
|
||||||
const tempBranch = uuidv4()
|
const tempBranch = randomUUID()
|
||||||
await git.checkout(tempBranch, 'HEAD')
|
await git.checkout(tempBranch, 'HEAD')
|
||||||
// Commit any uncommitted changes
|
// Commit any uncommitted changes
|
||||||
if (await git.isDirty(true, addPaths)) {
|
if (await git.isDirty(true, addPaths)) {
|
||||||
|
|||||||
@@ -127,7 +127,13 @@ export async function createPullRequest(inputs: Inputs): Promise<void> {
|
|||||||
// deleted after being merged or closed. Without this the push using
|
// deleted after being merged or closed. Without this the push using
|
||||||
// '--force-with-lease' fails due to "stale info."
|
// '--force-with-lease' fails due to "stale info."
|
||||||
// https://github.com/peter-evans/create-pull-request/issues/633
|
// https://github.com/peter-evans/create-pull-request/issues/633
|
||||||
await git.exec(['remote', 'prune', branchRemoteName])
|
try {
|
||||||
|
await git.exec(['remote', 'prune', branchRemoteName])
|
||||||
|
} catch (error) {
|
||||||
|
core.warning(
|
||||||
|
`Failed to prune remote '${branchRemoteName}': ${(error as Error).message}`
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
core.endGroup()
|
core.endGroup()
|
||||||
|
|
||||||
|
|||||||
+59
-26
@@ -1,7 +1,13 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {RequestError} from '@octokit/request-error'
|
||||||
import {Inputs} from './create-pull-request'
|
import {Inputs} from './create-pull-request'
|
||||||
import {Commit, GitCommandManager} from './git-command-manager'
|
import {Commit, GitCommandManager} from './git-command-manager'
|
||||||
import {Octokit, OctokitOptions, throttleOptions} from './octokit-client'
|
import {
|
||||||
|
Octokit,
|
||||||
|
OctokitOptions,
|
||||||
|
retryOptions,
|
||||||
|
throttleOptions
|
||||||
|
} from './octokit-client'
|
||||||
import pLimit from 'p-limit'
|
import pLimit from 'p-limit'
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
|
|
||||||
@@ -52,6 +58,7 @@ export class GitHubHelper {
|
|||||||
options.baseUrl = 'https://api.github.com'
|
options.baseUrl = 'https://api.github.com'
|
||||||
}
|
}
|
||||||
options.throttle = throttleOptions
|
options.throttle = throttleOptions
|
||||||
|
options.retry = retryOptions
|
||||||
this.octokit = new Octokit(options)
|
this.octokit = new Octokit(options)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,32 +210,51 @@ export class GitHubHelper {
|
|||||||
headRepository
|
headRepository
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// After creating a new PR, follow-up API calls can fail with a 422
|
||||||
|
// "Could not resolve to a node" error due to GitHub API eventual
|
||||||
|
// consistency. Wrap post-creation calls with targeted retry logic.
|
||||||
|
// See: https://github.com/peter-evans/create-pull-request/issues/4321
|
||||||
|
const isEventualConsistencyError = (e: unknown): boolean =>
|
||||||
|
e instanceof RequestError &&
|
||||||
|
e.status === 422 &&
|
||||||
|
e.message.includes('Could not resolve to a node')
|
||||||
|
const withRetryForNewPr = <T>(fn: () => Promise<T>): Promise<T> =>
|
||||||
|
pull.created
|
||||||
|
? utils.retryWithBackoff(fn, isEventualConsistencyError)
|
||||||
|
: fn()
|
||||||
|
|
||||||
// Apply milestone
|
// Apply milestone
|
||||||
if (inputs.milestone) {
|
if (inputs.milestone) {
|
||||||
core.info(`Applying milestone '${inputs.milestone}'`)
|
core.info(`Applying milestone '${inputs.milestone}'`)
|
||||||
await this.octokit.rest.issues.update({
|
await withRetryForNewPr(() =>
|
||||||
...this.parseRepository(baseRepository),
|
this.octokit.rest.issues.update({
|
||||||
issue_number: pull.number,
|
...this.parseRepository(baseRepository),
|
||||||
milestone: inputs.milestone
|
issue_number: pull.number,
|
||||||
})
|
milestone: inputs.milestone
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// Apply labels
|
// Apply labels
|
||||||
if (inputs.labels.length > 0) {
|
if (inputs.labels.length > 0) {
|
||||||
core.info(`Applying labels '${inputs.labels}'`)
|
core.info(`Applying labels '${inputs.labels}'`)
|
||||||
await this.octokit.rest.issues.addLabels({
|
await withRetryForNewPr(() =>
|
||||||
...this.parseRepository(baseRepository),
|
this.octokit.rest.issues.addLabels({
|
||||||
issue_number: pull.number,
|
...this.parseRepository(baseRepository),
|
||||||
labels: inputs.labels
|
issue_number: pull.number,
|
||||||
})
|
labels: inputs.labels
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
// Apply assignees
|
// Apply assignees
|
||||||
if (inputs.assignees.length > 0) {
|
if (inputs.assignees.length > 0) {
|
||||||
core.info(`Applying assignees '${inputs.assignees}'`)
|
core.info(`Applying assignees '${inputs.assignees}'`)
|
||||||
await this.octokit.rest.issues.addAssignees({
|
await withRetryForNewPr(() =>
|
||||||
...this.parseRepository(baseRepository),
|
this.octokit.rest.issues.addAssignees({
|
||||||
issue_number: pull.number,
|
...this.parseRepository(baseRepository),
|
||||||
assignees: inputs.assignees
|
issue_number: pull.number,
|
||||||
})
|
assignees: inputs.assignees
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request reviewers and team reviewers
|
// Request reviewers and team reviewers
|
||||||
@@ -244,11 +270,13 @@ export class GitHubHelper {
|
|||||||
}
|
}
|
||||||
if (Object.keys(requestReviewersParams).length > 0) {
|
if (Object.keys(requestReviewersParams).length > 0) {
|
||||||
try {
|
try {
|
||||||
await this.octokit.rest.pulls.requestReviewers({
|
await withRetryForNewPr(() =>
|
||||||
...this.parseRepository(baseRepository),
|
this.octokit.rest.pulls.requestReviewers({
|
||||||
pull_number: pull.number,
|
...this.parseRepository(baseRepository),
|
||||||
...requestReviewersParams
|
pull_number: pull.number,
|
||||||
})
|
...requestReviewersParams
|
||||||
|
})
|
||||||
|
)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
|
if (utils.getErrorMessage(e).includes(ERROR_PR_REVIEW_TOKEN_SCOPE)) {
|
||||||
core.error(
|
core.error(
|
||||||
@@ -304,11 +332,14 @@ export class GitHubHelper {
|
|||||||
commit.changes.map(async ({path, mode, status, dstSha}) => {
|
commit.changes.map(async ({path, mode, status, dstSha}) => {
|
||||||
if (mode === '160000') {
|
if (mode === '160000') {
|
||||||
// submodule
|
// submodule
|
||||||
core.info(`Creating tree object for submodule commit at '${path}'`)
|
core.info(
|
||||||
|
`Creating tree object for submodule commit at '${path}' with status '${status}'`
|
||||||
|
)
|
||||||
return <TreeObject>{
|
return <TreeObject>{
|
||||||
path,
|
path,
|
||||||
mode,
|
mode,
|
||||||
sha: dstSha,
|
// A deleted submodule has a null dstSha; a null sha deletes the entry
|
||||||
|
sha: status === 'D' ? null : dstSha,
|
||||||
type: 'commit'
|
type: 'commit'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -407,10 +438,12 @@ export class GitHubHelper {
|
|||||||
newHead: string
|
newHead: string
|
||||||
) {
|
) {
|
||||||
const repository = this.parseRepository(branchRepository)
|
const repository = this.parseRepository(branchRepository)
|
||||||
const branchExists = await this.octokit.rest.repos
|
// Check the git ref directly rather than using the branches API, which
|
||||||
.getBranch({
|
// follows branch rename redirects and can return a different branch.
|
||||||
|
const branchExists = await this.octokit.rest.git
|
||||||
|
.getRef({
|
||||||
...repository,
|
...repository,
|
||||||
branch: branch
|
ref: `heads/${branch}`
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
() => true,
|
() => true,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as core from '@actions/core'
|
|||||||
import {Octokit as OctokitCore} from '@octokit/core'
|
import {Octokit as OctokitCore} from '@octokit/core'
|
||||||
import {paginateRest} from '@octokit/plugin-paginate-rest'
|
import {paginateRest} from '@octokit/plugin-paginate-rest'
|
||||||
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
|
import {restEndpointMethods} from '@octokit/plugin-rest-endpoint-methods'
|
||||||
|
import {retry} from '@octokit/plugin-retry'
|
||||||
import {throttling} from '@octokit/plugin-throttling'
|
import {throttling} from '@octokit/plugin-throttling'
|
||||||
import {fetch} from 'node-fetch-native/proxy'
|
import {fetch} from 'node-fetch-native/proxy'
|
||||||
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
|
export {RestEndpointMethodTypes} from '@octokit/plugin-rest-endpoint-methods'
|
||||||
@@ -11,6 +12,7 @@ export {OctokitOptions} from '@octokit/core/dist-types/types'
|
|||||||
export const Octokit = OctokitCore.plugin(
|
export const Octokit = OctokitCore.plugin(
|
||||||
paginateRest,
|
paginateRest,
|
||||||
restEndpointMethods,
|
restEndpointMethods,
|
||||||
|
retry,
|
||||||
throttling,
|
throttling,
|
||||||
autoProxyAgent
|
autoProxyAgent
|
||||||
)
|
)
|
||||||
@@ -32,6 +34,11 @@ export const throttleOptions = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const retryOptions = {
|
||||||
|
// 429 is handled by the throttling plugin, so we exclude it from retry
|
||||||
|
doNotRetry: [400, 401, 403, 404, 410, 422, 429, 451]
|
||||||
|
}
|
||||||
|
|
||||||
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
|
// Octokit plugin to support the standard environment variables http_proxy, https_proxy and no_proxy
|
||||||
function autoProxyAgent(octokit: OctokitCore) {
|
function autoProxyAgent(octokit: OctokitCore) {
|
||||||
octokit.hook.before('request', options => {
|
octokit.hook.before('request', options => {
|
||||||
|
|||||||
@@ -140,3 +140,27 @@ export const isSelfHosted = (): boolean =>
|
|||||||
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
process.env['RUNNER_ENVIRONMENT'] !== 'github-hosted' &&
|
||||||
(process.env['AGENT_ISSELFHOSTED'] === '1' ||
|
(process.env['AGENT_ISSELFHOSTED'] === '1' ||
|
||||||
process.env['AGENT_ISSELFHOSTED'] === undefined)
|
process.env['AGENT_ISSELFHOSTED'] === undefined)
|
||||||
|
|
||||||
|
export async function retryWithBackoff<T>(
|
||||||
|
fn: () => Promise<T>,
|
||||||
|
shouldRetry: (error: unknown) => boolean,
|
||||||
|
maxRetries = 2,
|
||||||
|
delayMs = 1000
|
||||||
|
): Promise<T> {
|
||||||
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
||||||
|
try {
|
||||||
|
return await fn()
|
||||||
|
} catch (e) {
|
||||||
|
if (attempt < maxRetries && shouldRetry(e)) {
|
||||||
|
const delay = delayMs * Math.pow(2, attempt)
|
||||||
|
core.info(
|
||||||
|
`Request failed (attempt ${attempt + 1}/${maxRetries + 1}), retrying in ${delay}ms...`
|
||||||
|
)
|
||||||
|
await new Promise(resolve => setTimeout(resolve, delay))
|
||||||
|
} else {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new Error('Unexpected: retry loop exited without return or throw')
|
||||||
|
}
|
||||||
Reference in new issue
Block a user