Initial implementation of logDiffIfDirty
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user