mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
Initial implementation of logDiffIfDirty
This commit is contained in:
parent
96eeaf940a
commit
cb913cd286
18
README.md
18
README.md
@ -359,6 +359,24 @@ Note that it is generally bad practice to modify your branch
|
||||
in a CI Pipeline. However there are exceptions where this might
|
||||
be needed. (use with care).
|
||||
|
||||
_**required:** `false`_
|
||||
_**default:** false_
|
||||
|
||||
#### logDiffIfDirty
|
||||
|
||||
Print a summary of changed files if the branch is determined to be dirty.
|
||||
This can be useful in debugging the reason your project files changed unexpectedly.
|
||||
This option works independently of `allowDirtyBuild`.
|
||||
|
||||
```yaml
|
||||
- uses: webbertakken/unity-builder@<version>
|
||||
with:
|
||||
logDiffIfDirty: true
|
||||
```
|
||||
|
||||
_**required:** `false`_
|
||||
_**default:** false_
|
||||
|
||||
#### customParameters
|
||||
|
||||
Custom parameters to configure the build.
|
||||
|
17
action.yml
17
action.yml
@ -70,6 +70,23 @@ inputs:
|
||||
|
||||
Parameters must start with a hyphen (-) and may be followed by a value (without hyphen).
|
||||
Parameters without a value will be considered booleans (with a value of true).
|
||||
allowDirtyBuild:
|
||||
required: false
|
||||
default: ''
|
||||
description: >
|
||||
Allows the branch of the build to be dirty, and still generate the build.
|
||||
|
||||
Note that it is generally bad practice to modify your branch
|
||||
in a CI Pipeline. However there are exceptions where this might
|
||||
be needed. (use with care).
|
||||
logDiffIfDirty:
|
||||
required: false
|
||||
default: ''
|
||||
description: >
|
||||
Print a summary of changed files if the branch is determined to be dirty.
|
||||
|
||||
This can be useful in debugging the reason your project files changed unexpectedly.
|
||||
This option works independently of allowDirtyBuild.
|
||||
outputs: {}
|
||||
branding:
|
||||
icon: 'box'
|
||||
|
File diff suppressed because one or more lines are too long
@ -77,6 +77,12 @@ class Input {
|
||||
return input === 'true' ? 'true' : 'false';
|
||||
}
|
||||
|
||||
static get logDiffIfDirty() {
|
||||
const input = core.getInput('logDiffIfDirty') || 'false';
|
||||
|
||||
return input === 'true' ? 'true' : 'false';
|
||||
}
|
||||
|
||||
static get customParameters() {
|
||||
return core.getInput('customParameters') || '';
|
||||
}
|
||||
|
@ -232,6 +232,24 @@ describe('Input', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('logDiffIfDirty', () => {
|
||||
it('returns the default value', () => {
|
||||
expect(Input.logDiffIfDirty).toStrictEqual('false');
|
||||
});
|
||||
|
||||
it('returns true when string true is passed', () => {
|
||||
const spy = jest.spyOn(core, 'getInput').mockReturnValue('true');
|
||||
expect(Input.logDiffIfDirty).toStrictEqual('true');
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('returns false when string false is passed', () => {
|
||||
const spy = jest.spyOn(core, 'getInput').mockReturnValue('false');
|
||||
expect(Input.logDiffIfDirty).toStrictEqual('false');
|
||||
expect(spy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('customParameters', () => {
|
||||
it('returns the default value', () => {
|
||||
expect(Input.customParameters).toStrictEqual('');
|
||||
|
@ -13,6 +13,10 @@ export default class Versioning {
|
||||
return Input.allowDirtyBuild === 'true';
|
||||
}
|
||||
|
||||
static get logDiffIfDirty() {
|
||||
return Input.logDiffIfDirty === 'true';
|
||||
}
|
||||
|
||||
static get strategies() {
|
||||
return { None: 'None', Semantic: 'Semantic', Tag: 'Tag', Custom: 'Custom' };
|
||||
}
|
||||
@ -178,7 +182,12 @@ export default class Versioning {
|
||||
static async isDirty() {
|
||||
const output = await this.git(['status', '--porcelain']);
|
||||
|
||||
return output !== '';
|
||||
const dirty = output !== '';
|
||||
if (dirty && this.logDiffIfDirty) {
|
||||
await this.git(['--no-pager', 'diff']);
|
||||
}
|
||||
|
||||
return dirty;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user