mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-02-04 08:09:08 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44bde7feb9 | ||
|
|
5328bda08e | ||
|
|
34e4b86924 |
File diff suppressed because one or more lines are too long
@@ -26,4 +26,24 @@ expect.extend({
|
|||||||
pass,
|
pass,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toBeParsableToANumber(received) {
|
||||||
|
let pass = false;
|
||||||
|
let errorMessage = '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
Number.parseInt(received, 10);
|
||||||
|
pass = true;
|
||||||
|
} catch (error) {
|
||||||
|
errorMessage = error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const message = () => `Expected ${this.utils.printExpected(received)} to be parsable as a number
|
||||||
|
, but received error: ${this.utils.printReceived(errorMessage)}.`;
|
||||||
|
|
||||||
|
return {
|
||||||
|
message,
|
||||||
|
pass,
|
||||||
|
};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -44,5 +44,13 @@ describe('System', () => {
|
|||||||
expect(info).toHaveBeenCalledTimes(2);
|
expect(info).toHaveBeenCalledTimes(2);
|
||||||
expect(info).toHaveBeenLastCalledWith('3\n');
|
expect(info).toHaveBeenLastCalledWith('3\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('allows pipes using buffer', async () => {
|
||||||
|
await expect(
|
||||||
|
System.run('sh', undefined, {
|
||||||
|
input: Buffer.from('git tag --list --merged HEAD | grep v[0-9]* | wc -l'),
|
||||||
|
}),
|
||||||
|
).resolves.toBeParsableToANumber();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -183,25 +183,27 @@ export default class Versioning {
|
|||||||
* Whether or not the repository has any version tags yet.
|
* Whether or not the repository has any version tags yet.
|
||||||
*/
|
*/
|
||||||
static async hasAnyVersionTags() {
|
static async hasAnyVersionTags() {
|
||||||
const numberOfVersionCommits = await System.run('git', [
|
const numberOfCommitsAsString = await System.run('sh', undefined, {
|
||||||
'tag',
|
input: Buffer.from('git tag --list --merged HEAD | grep v[0-9]* | wc -l'),
|
||||||
'--list',
|
silent: false,
|
||||||
'--merged',
|
});
|
||||||
'HEAD',
|
|
||||||
'|',
|
|
||||||
'grep v[0-9]*',
|
|
||||||
'|',
|
|
||||||
'wc -l',
|
|
||||||
]);
|
|
||||||
|
|
||||||
return numberOfVersionCommits !== '0';
|
const numberOfCommits = Number.parseInt(numberOfCommitsAsString, 10);
|
||||||
|
|
||||||
|
return numberOfCommits !== 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the total number of commits on head.
|
* Get the total number of commits on head.
|
||||||
|
*
|
||||||
|
* Note: HEAD should not be used, as it may be detached, resulting in an additional count.
|
||||||
*/
|
*/
|
||||||
static async getTotalNumberOfCommits() {
|
static async getTotalNumberOfCommits() {
|
||||||
const numberOfCommitsAsString = await System.run('git', ['rev-list', '--count', 'HEAD']);
|
const numberOfCommitsAsString = await System.run('git', [
|
||||||
|
'rev-list',
|
||||||
|
'--count',
|
||||||
|
`origin/${this.branch}`,
|
||||||
|
]);
|
||||||
|
|
||||||
return Number.parseInt(numberOfCommitsAsString, 10);
|
return Number.parseInt(numberOfCommitsAsString, 10);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user