Skip to content

Commit 461fc92

Browse files
authored
ci: fix submodule diff error (#120)
1 parent 6c80613 commit 461fc92

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

.github/workflows/main.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ jobs:
6868
const package = JSON.parse(await fs.readFile('package.json', 'utf8'));
6969
const old = package.swiftorg.commit;
7070
try {
71-
await exec.exec('git', ['submodule', 'update', '--init']);
71+
await exec.exec('git', ['submodule', 'update', '--init', '--no-recommend-shallow', '--checkout']);
72+
try {
73+
await exec.exec('git', ['fetch', '--unshallow'], { cwd: 'swiftorg' });
74+
} catch (error) {
75+
core.warning(error);
76+
}
7277
const { stdout } = await exec.getExecOutput('git', ['diff', '--name-status', '--ignore-submodules=all', '--diff-filter=ACDMRTUX', `${old}..HEAD`], { cwd: 'swiftorg' });
7378
const files = stdout.split('\n').filter(Boolean).flatMap((line) => {
7479
const parts = line.split('\t');

__tests__/swiftorg.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ describe('swiftorg sync validation', () => {
1616
await swiftorg.update()
1717
expect(rmSpy).not.toHaveBeenCalled()
1818
expect(execSpy).toHaveBeenCalledTimes(2)
19-
const gitArgs = ['submodule', 'update', '--init', '--recursive', '--remote']
19+
const gitArgs = [
20+
'submodule',
21+
'update',
22+
'--init',
23+
'--checkout',
24+
'--recursive',
25+
'--remote'
26+
]
2027
expect(execSpy.mock.calls[1]).toStrictEqual([
2128
'git',
2229
gitArgs,
@@ -32,7 +39,7 @@ describe('swiftorg sync validation', () => {
3239
await swiftorg.update()
3340
expect(rmSpy).not.toHaveBeenCalled()
3441
expect(execSpy).toHaveBeenCalledTimes(2)
35-
const gitArgs = ['submodule', 'update', '--init']
42+
const gitArgs = ['submodule', 'update', '--init', '--checkout']
3643
expect(execSpy.mock.calls[1]).toStrictEqual([
3744
'git',
3845
gitArgs,

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"ci"
101101
],
102102
"scripts": {
103-
"prepare": "npm run build && git submodule update --init",
103+
"prepare": "npm run build && git submodule update --init --checkout",
104104
"build": "tsc",
105105
"format": "prettier --write \"**/*.ts\"",
106106
"lint": "depcheck --ignores ts-node,ts-jest && eslint src/**/*.ts && prettier --check \"**/*.ts\"",

src/swiftorg.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export class Swiftorg {
4646
}
4747

4848
async update() {
49-
const gitArgs = ['submodule', 'update', '--init']
49+
const gitArgs = ['submodule', 'update', '--init', '--checkout']
5050
if (this.checkLatest) {
5151
gitArgs.push('--recursive', '--remote')
5252
}

0 commit comments

Comments
 (0)