mirror of
https://forgejo.stefka.eu/jiriks74/create-pull-request.git
synced 2025-01-18 16:01:06 +01:00
feat: allow add-paths to resolve to no changes
This commit is contained in:
parent
0e8dfbd57d
commit
1b9df9cea0
6 changed files with 174 additions and 89 deletions
|
@ -46,7 +46,7 @@ All inputs are **optional**. If not set, sensible defaults will be used.
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `token` | `GITHUB_TOKEN` (permissions `contents: write` and `pull-requests: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
|
| `token` | `GITHUB_TOKEN` (permissions `contents: write` and `pull-requests: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). | `GITHUB_TOKEN` |
|
||||||
| `path` | Relative path under `GITHUB_WORKSPACE` to the repository. | `GITHUB_WORKSPACE` |
|
| `path` | Relative path under `GITHUB_WORKSPACE` to the repository. | `GITHUB_WORKSPACE` |
|
||||||
| `add-paths` | A comma or newline-separated list of file paths to commit. Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax. Defaults to adding all new and modified files. See [Add specific paths](#add-specific-paths). | `-A` |
|
| `add-paths` | A comma or newline-separated list of file paths to commit. Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax. If no paths are specified, all new and modified files are added. See [Add specific paths](#add-specific-paths). | |
|
||||||
| `commit-message` | The message to use when committing changes. | `[create-pull-request] automated change` |
|
| `commit-message` | The message to use when committing changes. | `[create-pull-request] automated change` |
|
||||||
| `committer` | The committer name and email address in the format `Display Name <email@address.com>`. Defaults to the GitHub Actions bot user. | `GitHub <noreply@github.com>` |
|
| `committer` | The committer name and email address in the format `Display Name <email@address.com>`. Defaults to the GitHub Actions bot user. | `GitHub <noreply@github.com>` |
|
||||||
| `author` | The author name and email address in the format `Display Name <email@address.com>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>` |
|
| `author` | The author name and email address in the format `Display Name <email@address.com>`. Defaults to the user who triggered the workflow run. | `${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>` |
|
||||||
|
@ -147,7 +147,6 @@ If there are files or directories you want to ignore you can simply add them to
|
||||||
|
|
||||||
You can control which files are committed with the `add-paths` input.
|
You can control which files are committed with the `add-paths` input.
|
||||||
Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax.
|
Paths should follow git's [pathspec](https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec) syntax.
|
||||||
Each path must resolve to a least one new or modified file to add.
|
|
||||||
All file changes that do not match one of the paths will be discarded.
|
All file changes that do not match one of the paths will be discarded.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
|
|
|
@ -11,8 +11,8 @@ import {v4 as uuidv4} from 'uuid'
|
||||||
const REPO_PATH = '/git/local/test-base'
|
const REPO_PATH = '/git/local/test-base'
|
||||||
const REMOTE_NAME = 'origin'
|
const REMOTE_NAME = 'origin'
|
||||||
|
|
||||||
const TRACKED_FILE = 'tracked-file.txt'
|
const TRACKED_FILE = 'a/tracked-file.txt'
|
||||||
const UNTRACKED_FILE = 'untracked-file.txt'
|
const UNTRACKED_FILE = 'b/untracked-file.txt'
|
||||||
|
|
||||||
const DEFAULT_BRANCH = 'tests/master'
|
const DEFAULT_BRANCH = 'tests/master'
|
||||||
const NOT_BASE_BRANCH = 'tests/branch-that-is-not-the-base'
|
const NOT_BASE_BRANCH = 'tests/branch-that-is-not-the-base'
|
||||||
|
@ -25,12 +25,14 @@ const BASE = DEFAULT_BRANCH
|
||||||
const FORK_REMOTE_URL = 'git://127.0.0.1/test-fork.git'
|
const FORK_REMOTE_URL = 'git://127.0.0.1/test-fork.git'
|
||||||
const FORK_REMOTE_NAME = 'fork'
|
const FORK_REMOTE_NAME = 'fork'
|
||||||
|
|
||||||
const ADD_PATHS = ['-A']
|
const ADD_PATHS_DEFAULT = []
|
||||||
const ADD_PATHS_WILDCARD = ['*.txt']
|
const ADD_PATHS_MULTI = ['a', 'b']
|
||||||
|
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 : uuidv4()
|
||||||
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.writeFile(filepath, _content, {encoding: 'utf8'})
|
await fs.promises.writeFile(filepath, _content, {encoding: 'utf8'})
|
||||||
return _content
|
return _content
|
||||||
}
|
}
|
||||||
|
@ -224,7 +226,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('none')
|
expect(result.action).toEqual('none')
|
||||||
expect(await gitLogMatches([INIT_COMMIT_MESSAGE])).toBeTruthy()
|
expect(await gitLogMatches([INIT_COMMIT_MESSAGE])).toBeTruthy()
|
||||||
|
@ -241,7 +243,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(trackedContent)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(trackedContent)
|
||||||
|
@ -269,7 +271,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -290,7 +292,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(UNTRACKED_FILE)).toEqual(untrackedContent)
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(untrackedContent)
|
||||||
|
@ -318,7 +320,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -341,7 +343,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -370,7 +372,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('not-updated')
|
expect(_result.action).toEqual('not-updated')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -391,7 +393,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -428,7 +430,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -459,7 +461,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -487,7 +489,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -508,7 +510,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -548,7 +550,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -575,7 +577,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -618,7 +620,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -640,7 +642,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(commits.changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(commits.changes.tracked)
|
||||||
|
@ -671,7 +673,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -697,7 +699,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -732,7 +734,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -760,7 +762,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -803,7 +805,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -830,7 +832,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
FORK_REMOTE_NAME,
|
FORK_REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -859,7 +861,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
FORK_REMOTE_NAME,
|
FORK_REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -881,7 +883,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
true,
|
true,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -917,7 +919,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
true,
|
true,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -935,9 +937,58 @@ describe('create-or-update-branch tests', () => {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tests create and update with wildcard add-paths', async () => {
|
it('tests create and update with multiple add-paths', async () => {
|
||||||
// The pull request branch will not be updated
|
// Create tracked and untracked file changes
|
||||||
|
const changes = await createChanges()
|
||||||
|
const commitMessage = uuidv4()
|
||||||
|
const result = await createOrUpdateBranch(
|
||||||
|
git,
|
||||||
|
commitMessage,
|
||||||
|
'',
|
||||||
|
BRANCH,
|
||||||
|
REMOTE_NAME,
|
||||||
|
false,
|
||||||
|
ADD_PATHS_MULTI
|
||||||
|
)
|
||||||
|
expect(result.action).toEqual('created')
|
||||||
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(changes.untracked)
|
||||||
|
expect(
|
||||||
|
await gitLogMatches([commitMessage, INIT_COMMIT_MESSAGE])
|
||||||
|
).toBeTruthy()
|
||||||
|
|
||||||
|
// Push pull request branch to remote
|
||||||
|
await git.push([
|
||||||
|
'--force-with-lease',
|
||||||
|
REMOTE_NAME,
|
||||||
|
`HEAD:refs/heads/${BRANCH}`
|
||||||
|
])
|
||||||
|
|
||||||
|
await afterTest(false)
|
||||||
|
await beforeTest()
|
||||||
|
|
||||||
|
// Create tracked and untracked file changes
|
||||||
|
const _changes = await createChanges()
|
||||||
|
const _commitMessage = uuidv4()
|
||||||
|
const _result = await createOrUpdateBranch(
|
||||||
|
git,
|
||||||
|
_commitMessage,
|
||||||
|
'',
|
||||||
|
BRANCH,
|
||||||
|
REMOTE_NAME,
|
||||||
|
false,
|
||||||
|
ADD_PATHS_MULTI
|
||||||
|
)
|
||||||
|
expect(_result.action).toEqual('updated')
|
||||||
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
expect(await getFileContent(TRACKED_FILE)).toEqual(_changes.tracked)
|
||||||
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(_changes.untracked)
|
||||||
|
expect(
|
||||||
|
await gitLogMatches([_commitMessage, INIT_COMMIT_MESSAGE])
|
||||||
|
).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
|
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 = uuidv4()
|
||||||
|
@ -988,6 +1039,23 @@ describe('create-or-update-branch tests', () => {
|
||||||
).toBeTruthy()
|
).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('tests create with add-paths resolving to no changes when other changes exist', async () => {
|
||||||
|
// Create tracked and untracked file changes
|
||||||
|
await createChanges()
|
||||||
|
const commitMessage = uuidv4()
|
||||||
|
const result = await createOrUpdateBranch(
|
||||||
|
git,
|
||||||
|
commitMessage,
|
||||||
|
'',
|
||||||
|
BRANCH,
|
||||||
|
REMOTE_NAME,
|
||||||
|
false,
|
||||||
|
['nonexistent/*']
|
||||||
|
)
|
||||||
|
expect(result.action).toEqual('none')
|
||||||
|
expect(await gitLogMatches([INIT_COMMIT_MESSAGE])).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
// Working Base is Not Base (WBNB)
|
// Working Base is Not Base (WBNB)
|
||||||
|
|
||||||
it('tests no changes resulting in no new branch being created (WBNB)', async () => {
|
it('tests no changes resulting in no new branch being created (WBNB)', async () => {
|
||||||
|
@ -1002,7 +1070,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('none')
|
expect(result.action).toEqual('none')
|
||||||
expect(await gitLogMatches([INIT_COMMIT_MESSAGE])).toBeTruthy()
|
expect(await gitLogMatches([INIT_COMMIT_MESSAGE])).toBeTruthy()
|
||||||
|
@ -1022,7 +1090,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(trackedContent)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(trackedContent)
|
||||||
|
@ -1053,7 +1121,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1077,7 +1145,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(UNTRACKED_FILE)).toEqual(untrackedContent)
|
expect(await getFileContent(UNTRACKED_FILE)).toEqual(untrackedContent)
|
||||||
|
@ -1108,7 +1176,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1134,7 +1202,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1166,7 +1234,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('not-updated')
|
expect(_result.action).toEqual('not-updated')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1190,7 +1258,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1230,7 +1298,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1264,7 +1332,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1295,7 +1363,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -1321,7 +1389,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1364,7 +1432,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -1394,7 +1462,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1440,7 +1508,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeFalsy()
|
expect(_result.hasDiffWithBase).toBeFalsy()
|
||||||
|
@ -1465,7 +1533,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(commits.changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(commits.changes.tracked)
|
||||||
|
@ -1499,7 +1567,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1528,7 +1596,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1566,7 +1634,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1597,7 +1665,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1643,7 +1711,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1673,7 +1741,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
FORK_REMOTE_NAME,
|
FORK_REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1705,7 +1773,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
FORK_REMOTE_NAME,
|
FORK_REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1734,7 +1802,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1767,7 +1835,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1793,7 +1861,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(result.action).toEqual('created')
|
expect(result.action).toEqual('created')
|
||||||
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
expect(await getFileContent(TRACKED_FILE)).toEqual(changes.tracked)
|
||||||
|
@ -1834,7 +1902,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
expect(_result.action).toEqual('updated')
|
expect(_result.action).toEqual('updated')
|
||||||
expect(_result.hasDiffWithBase).toBeTruthy()
|
expect(_result.hasDiffWithBase).toBeTruthy()
|
||||||
|
@ -1866,7 +1934,7 @@ describe('create-or-update-branch tests', () => {
|
||||||
BRANCH,
|
BRANCH,
|
||||||
REMOTE_NAME,
|
REMOTE_NAME,
|
||||||
false,
|
false,
|
||||||
ADD_PATHS
|
ADD_PATHS_DEFAULT
|
||||||
)
|
)
|
||||||
// The action cannot successfully create the branch
|
// The action cannot successfully create the branch
|
||||||
expect(result.action).toEqual('none')
|
expect(result.action).toEqual('none')
|
||||||
|
|
|
@ -13,8 +13,6 @@ inputs:
|
||||||
A comma or newline-separated list of file paths to commit.
|
A comma or newline-separated list of file paths to commit.
|
||||||
Paths should follow git's pathspec syntax.
|
Paths should follow git's pathspec syntax.
|
||||||
Defaults to adding all new and modified files.
|
Defaults to adding all new and modified files.
|
||||||
default: |
|
|
||||||
-A
|
|
||||||
commit-message:
|
commit-message:
|
||||||
description: 'The message to use when committing changes.'
|
description: 'The message to use when committing changes.'
|
||||||
default: '[create-pull-request] automated change'
|
default: '[create-pull-request] automated change'
|
||||||
|
|
36
dist/index.js
vendored
36
dist/index.js
vendored
|
@ -122,20 +122,25 @@ function createOrUpdateBranch(git, commitMessage, base, branch, branchRemoteName
|
||||||
const tempBranch = (0, uuid_1.v4)();
|
const tempBranch = (0, uuid_1.v4)();
|
||||||
yield git.checkout(tempBranch, 'HEAD');
|
yield git.checkout(tempBranch, 'HEAD');
|
||||||
// Commit any uncommitted changes
|
// Commit any uncommitted changes
|
||||||
if (yield git.isDirty(true)) {
|
if (yield git.isDirty(true, addPaths)) {
|
||||||
core.info('Uncommitted changes found. Adding a commit.');
|
core.info('Uncommitted changes found. Adding a commit.');
|
||||||
for (const path of addPaths) {
|
const aopts = ['add'];
|
||||||
yield git.exec(['add', path], true);
|
if (addPaths.length > 0) {
|
||||||
|
aopts.push(...['--', ...addPaths]);
|
||||||
}
|
}
|
||||||
const params = ['-m', commitMessage];
|
else {
|
||||||
|
aopts.push('-A');
|
||||||
|
}
|
||||||
|
yield git.exec(aopts, true);
|
||||||
|
const popts = ['-m', commitMessage];
|
||||||
if (signoff) {
|
if (signoff) {
|
||||||
params.push('--signoff');
|
popts.push('--signoff');
|
||||||
}
|
}
|
||||||
yield git.commit(params);
|
yield git.commit(popts);
|
||||||
// Remove uncommitted tracked and untracked changes
|
|
||||||
yield git.exec(['reset', '--hard']);
|
|
||||||
yield git.exec(['clean', '-f']);
|
|
||||||
}
|
}
|
||||||
|
// Remove uncommitted tracked and untracked changes
|
||||||
|
yield git.exec(['reset', '--hard']);
|
||||||
|
yield git.exec(['clean', '-f', '-d']);
|
||||||
// Perform fetch and reset the working base
|
// Perform fetch and reset the working base
|
||||||
// Commits made during the workflow will be removed
|
// Commits made during the workflow will be removed
|
||||||
if (workingBaseType == WorkingBaseType.Branch) {
|
if (workingBaseType == WorkingBaseType.Branch) {
|
||||||
|
@ -752,18 +757,23 @@ class GitCommandManager {
|
||||||
return output.exitCode === 1;
|
return output.exitCode === 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
isDirty(untracked) {
|
isDirty(untracked, pathspec) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const pathspecArgs = pathspec ? ['--', ...pathspec] : [];
|
||||||
// Check untracked changes
|
// Check untracked changes
|
||||||
if (untracked && (yield this.status(['--porcelain', '-unormal']))) {
|
const sargs = ['--porcelain', '-unormal'];
|
||||||
|
sargs.push(...pathspecArgs);
|
||||||
|
if (untracked && (yield this.status(sargs))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check working index changes
|
// Check working index changes
|
||||||
if (yield this.hasDiff()) {
|
if (yield this.hasDiff(pathspecArgs)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Check staged changes
|
// Check staged changes
|
||||||
if (yield this.hasDiff(['--staged'])) {
|
const dargs = ['--staged'];
|
||||||
|
dargs.push(...pathspecArgs);
|
||||||
|
if (yield this.hasDiff(dargs)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -119,21 +119,26 @@ export async function createOrUpdateBranch(
|
||||||
const tempBranch = uuidv4()
|
const tempBranch = uuidv4()
|
||||||
await git.checkout(tempBranch, 'HEAD')
|
await git.checkout(tempBranch, 'HEAD')
|
||||||
// Commit any uncommitted changes
|
// Commit any uncommitted changes
|
||||||
if (await git.isDirty(true)) {
|
if (await git.isDirty(true, addPaths)) {
|
||||||
core.info('Uncommitted changes found. Adding a commit.')
|
core.info('Uncommitted changes found. Adding a commit.')
|
||||||
for (const path of addPaths) {
|
const aopts = ['add']
|
||||||
await git.exec(['add', path], true)
|
if (addPaths.length > 0) {
|
||||||
|
aopts.push(...['--', ...addPaths])
|
||||||
|
} else {
|
||||||
|
aopts.push('-A')
|
||||||
}
|
}
|
||||||
const params = ['-m', commitMessage]
|
await git.exec(aopts, true)
|
||||||
|
const popts = ['-m', commitMessage]
|
||||||
if (signoff) {
|
if (signoff) {
|
||||||
params.push('--signoff')
|
popts.push('--signoff')
|
||||||
}
|
}
|
||||||
await git.commit(params)
|
await git.commit(popts)
|
||||||
// Remove uncommitted tracked and untracked changes
|
|
||||||
await git.exec(['reset', '--hard'])
|
|
||||||
await git.exec(['clean', '-f'])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove uncommitted tracked and untracked changes
|
||||||
|
await git.exec(['reset', '--hard'])
|
||||||
|
await git.exec(['clean', '-f', '-d'])
|
||||||
|
|
||||||
// Perform fetch and reset the working base
|
// Perform fetch and reset the working base
|
||||||
// Commits made during the workflow will be removed
|
// Commits made during the workflow will be removed
|
||||||
if (workingBaseType == WorkingBaseType.Branch) {
|
if (workingBaseType == WorkingBaseType.Branch) {
|
||||||
|
|
|
@ -155,17 +155,22 @@ export class GitCommandManager {
|
||||||
return output.exitCode === 1
|
return output.exitCode === 1
|
||||||
}
|
}
|
||||||
|
|
||||||
async isDirty(untracked: boolean): Promise<boolean> {
|
async isDirty(untracked: boolean, pathspec?: string[]): Promise<boolean> {
|
||||||
|
const pathspecArgs = pathspec ? ['--', ...pathspec] : []
|
||||||
// Check untracked changes
|
// Check untracked changes
|
||||||
if (untracked && (await this.status(['--porcelain', '-unormal']))) {
|
const sargs = ['--porcelain', '-unormal']
|
||||||
|
sargs.push(...pathspecArgs)
|
||||||
|
if (untracked && (await this.status(sargs))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Check working index changes
|
// Check working index changes
|
||||||
if (await this.hasDiff()) {
|
if (await this.hasDiff(pathspecArgs)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Check staged changes
|
// Check staged changes
|
||||||
if (await this.hasDiff(['--staged'])) {
|
const dargs = ['--staged']
|
||||||
|
dargs.push(...pathspecArgs)
|
||||||
|
if (await this.hasDiff(dargs)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue