Skip to content

Commit 800126f

Browse files
committed
fix(ng-dev/release): skip commit in snapshot repository if no changes are detected
When publishing snapshots, it's possible that a package is built but contains no functional changes compared to the previous snapshot (e.g. only version placeholder changes which are ignored by the diff). Previously, we would still attempt to run `git commit`, which would fail if no changes were staged. This change wraps the commit call in a check for changes, avoiding empty commits or errors.
1 parent f719348 commit 800126f

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

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

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,19 @@ export class SnapshotPublisher {
161161
['diff-index', '--quiet', '-I', '0\\.0\\.0-[a-f0-9]+', 'HEAD', '--'],
162162
{cwd: tmpRepoDir},
163163
).status === 1;
164-
this.git.run(
165-
[
166-
'commit',
167-
'--author',
168-
this.commitAuthor,
169-
'-m',
170-
`"${this.snapshotCommitMessage.replace(/"/g, '\\"')}"`,
171-
],
172-
{cwd: tmpRepoDir},
173-
);
164+
165+
if (containsChanges) {
166+
this.git.run(
167+
[
168+
'commit',
169+
'--author',
170+
this.commitAuthor,
171+
'-m',
172+
`"${this.snapshotCommitMessage.replace(/"/g, '\\"')}"`,
173+
],
174+
{cwd: tmpRepoDir},
175+
);
176+
}
174177

175178
return {
176179
url,

0 commit comments

Comments
 (0)