mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
use System.run for logging Git diff
This commit is contained in:
parent
91ec427695
commit
fdf71758a9
File diff suppressed because one or more lines are too long
@ -57,7 +57,10 @@ export default class Versioning {
|
||||
* Log up to maxDiffLines of the git diff.
|
||||
*/
|
||||
static async logDiff() {
|
||||
this.git(['--no-pager', 'diff', '|', 'head', '-n', this.maxDiffLines.toString()]);
|
||||
await System.run('sh', undefined, {
|
||||
input: Buffer.from(`git --no-pager diff | head -n ${this.maxDiffLines.toString()}`),
|
||||
silent: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,15 +111,14 @@ describe('Versioning', () => {
|
||||
.spyOn(Versioning, 'parseSemanticVersion')
|
||||
.mockResolvedValue({ tag: 'mocktag', commits: 'abcdef', hash: '75822BCAF' });
|
||||
const logDiffSpy = jest.spyOn(Versioning, 'logDiff');
|
||||
const gitSpy = jest
|
||||
.spyOn(Versioning, 'git')
|
||||
.mockReturnValue('There is a diff actually! \n M My_Dirty_File.txt');
|
||||
const gitSpy = jest.spyOn(System, 'run').mockResolvedValue({});
|
||||
|
||||
await Versioning.generateSemanticVersion();
|
||||
|
||||
expect(logDiffSpy).toHaveBeenCalledTimes(1);
|
||||
expect(gitSpy).toHaveBeenCalledTimes(1);
|
||||
expect(Versioning.git.mock.calls[0][0].indexOf('diff')).toBeGreaterThan(-1);
|
||||
const issuedCommand = System.run.mock.calls[0][2].input.toString();
|
||||
expect(issuedCommand.indexOf('diff')).toBeGreaterThan(-1);
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user