Skip to content

Commit

Permalink
fix(impact): fix impacted files not accurately reported
Browse files Browse the repository at this point in the history
  • Loading branch information
azlam-abdulsalam committed Jan 9, 2024
1 parent 010834a commit 2be31ec
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/sfp-cli/src/core/git/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ export default class Git {
return git;
}

public raw(commands: string[]) {
return this._git.raw(commands);
}

public getRepositoryPath() {
return this.repositoryLocation;
}
Expand Down
9 changes: 6 additions & 3 deletions packages/sfp-cli/src/core/package/diff/PackageDiffImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export default class PackageDiffImpl {
try {
if(this.diffOptions?.useBranchCompare)
{
modified_files = await git.diff(['--name-only', `${this.diffOptions.baseBranch}..${this.diffOptions.branch}`]);
const mergeBase = await git.raw(['merge-base', this.diffOptions.branch, this.diffOptions.baseBranch]);
modified_files = await git.diff(['--name-only', this.diffOptions.branch, mergeBase.trim()]);
}
else
{
Expand Down Expand Up @@ -110,8 +111,10 @@ export default class PackageDiffImpl {

if(this.diffOptions?.useBranchCompare)
{
let modified_files = await git.diff(['--name-only', `${this.diffOptions.baseBranch}..${this.diffOptions.branch}`]);
// Check whether the package has been modified
const mergeBase = await git.raw(['merge-base', this.diffOptions.branch, this.diffOptions.baseBranch]);
let modified_files = await git.diff(['--name-only', this.diffOptions.branch,, mergeBase.trim()]);

// Check whether the package has been modified
for (let filename of modified_files) {

let normalizedPkgPath = path.normalize(pkgDescriptor.path);
Expand Down

0 comments on commit 2be31ec

Please sign in to comment.