Skip to content

Commit a92f257

Browse files
committed
Fix an issue where rush change will detect unrelated changes.
1 parent 8d1f4c0 commit a92f257

1 file changed

Lines changed: 10 additions & 12 deletions

File tree

‎apps/rush-lib/src/utilities/VersionControl.ts‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class VersionControl {
1515
skipFetch: boolean = false
1616
): Array<string | undefined> | undefined {
1717
if (!skipFetch) {
18-
VersionControl._fetchNonDefaultBranch(targetBranch);
18+
VersionControl._fetchRemoteBranch(targetBranch);
1919
}
2020

2121
const output: string = child_process.execSync(`git diff ${targetBranch}... --dirstat=files,0`).toString();
@@ -36,11 +36,11 @@ export class VersionControl {
3636
* @returns
3737
* An array of paths of repo-root-relative paths of files that are different from
3838
* those in the provided {@param targetBranch}. If a {@param pathPrefix} is provided,
39-
* this function only returns reuslts under the that path.
39+
* this function only returns results under the that path.
4040
*/
4141
public static getChangedFiles(targetBranch: string, skipFetch: boolean = false, pathPrefix?: string): string[] {
4242
if (!skipFetch) {
43-
VersionControl._fetchNonDefaultBranch(targetBranch);
43+
VersionControl._fetchRemoteBranch(targetBranch);
4444
}
4545

4646
const output: string = child_process.execSync(
@@ -170,15 +170,13 @@ export class VersionControl {
170170
return spawnResult.status === 0;
171171
}
172172

173-
private static _fetchNonDefaultBranch(remoteBranchName: string): void {
174-
if (remoteBranchName !== DEFAULT_FULLY_QUALIFIED_BRANCH) {
175-
console.log(`Checking for updates to ${remoteBranchName}...`);
176-
const fetchResult: boolean = VersionControl._tryFetchRemoteBranch(remoteBranchName);
177-
if (!fetchResult) {
178-
console.log(colors.yellow(
179-
`Error fetching git remote branch ${remoteBranchName}. Detected changed files may be incorrect.`
180-
));
181-
}
173+
private static _fetchRemoteBranch(remoteBranchName: string): void {
174+
console.log(`Checking for updates to ${remoteBranchName}...`);
175+
const fetchResult: boolean = VersionControl._tryFetchRemoteBranch(remoteBranchName);
176+
if (!fetchResult) {
177+
console.log(colors.yellow(
178+
`Error fetching git remote branch ${remoteBranchName}. Detected changed files may be incorrect.`
179+
));
182180
}
183181
}
184182
}

0 commit comments

Comments
 (0)