Skip to content

Commit eebc3dc

Browse files
author
Nicholas Pape
authored
Fix issue with "git commit" not having any files added to index (microsoft#452)
* Add a check to onlyu do the second add changes and commit if the package.json has been changed * code review comment
1 parent 3615b1f commit eebc3dc

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎apps/rush-lib/src/cli/actions/VersionAction.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ export default class VersionAction extends BaseRushAction {
144144
// Make changes in temp branch.
145145
git.checkout(tempBranch, true);
146146

147+
const uncommittedChanges: ReadonlyArray<string> = VersionControl.getUncommittedChanges();
148+
147149
// Stage, commit, and push the changes to remote temp branch.
148150
// Need to commit the change log updates in its own commit
149-
const changeLogUpdated: boolean = VersionControl.getUncommittedChanges().some((changePath) => {
151+
const changeLogUpdated: boolean = uncommittedChanges.some((changePath) => {
150152
return changePath.indexOf('CHANGELOG.json') > 0;
151153
});
152154

@@ -158,8 +160,15 @@ export default class VersionAction extends BaseRushAction {
158160
}
159161

160162
// Commit the package.json and change files updates.
161-
git.addChanges();
162-
git.commit();
163+
const packageJsonUpdated: boolean = uncommittedChanges.some((changePath) => {
164+
return changePath.indexOf('package.json') > 0;
165+
});
166+
167+
if (packageJsonUpdated) {
168+
git.addChanges();
169+
git.commit();
170+
}
171+
163172
git.push(tempBranch);
164173

165174
// Now merge to target branch.

0 commit comments

Comments
 (0)