Skip to content

Commit 632c25f

Browse files
josephperrottalan-agius4
authored andcommitted
fix(ng-dev/release): correctly identify unchanged repositories for snapshots
1 parent a2b14b2 commit 632c25f

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

ng-dev/release/snapshot-publish/snapshots.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ interface SnapshotRepo {
2828
dir: string;
2929
url: string;
3030
name: string;
31+
containsChanges: boolean;
3132
}
3233

3334
export class SnapshotPublisher {
@@ -155,6 +156,11 @@ export class SnapshotPublisher {
155156
);
156157
cpSync(pkg.outputPath, tmpRepoDir, {recursive: true});
157158
this.git.run(['add', '-A'], {cwd: tmpRepoDir});
159+
const containsChanges =
160+
this.git.runGraceful(
161+
['diff-index', '--quiet', '-I', '0\\.0\\.0-[a-f0-9]+', 'HEAD', '--'],
162+
{cwd: tmpRepoDir},
163+
).status === 1;
158164
this.git.run(['commit', '--author', this.commitAuthor, '-m', this.snapshotCommitMessage], {
159165
cwd: tmpRepoDir,
160166
});
@@ -163,6 +169,7 @@ export class SnapshotPublisher {
163169
url,
164170
dir: tmpRepoDir,
165171
name: pkg.name,
172+
containsChanges,
166173
};
167174
}),
168175
);
@@ -173,19 +180,12 @@ export class SnapshotPublisher {
173180
*/
174181
async publishSnapshots(snapshots: SnapshotRepo[]): Promise<void> {
175182
Log.info(bold(`Publishing snapshots to GitHub...`));
176-
for (const {name, dir, url} of snapshots) {
177-
if (this.flags.skipNonAffectedSnapshots) {
178-
const requiresPublish =
179-
this.git.runGraceful(
180-
['diff-index', '--quiet', '-I', '0\\.0\\.0-[a-f0-9]+', 'HEAD', '--'],
181-
{cwd: dir},
182-
).status !== 0;
183-
if (!requiresPublish) {
184-
Log.info(
185-
` ${yellow('⚠')} Skipping snapshot publish for ${name} as no changes occurred between this and the previous commit.`,
186-
);
187-
continue;
188-
}
183+
for (const {name, dir, url, containsChanges} of snapshots) {
184+
if (this.flags.skipNonAffectedSnapshots && !containsChanges) {
185+
Log.info(
186+
` ${yellow('⚠')} Skipping snapshot publish for ${name} as no changes occurred between this and the previous commit.`,
187+
);
188+
continue;
189189
}
190190

191191
if (this.flags.dryRun) {

0 commit comments

Comments
 (0)