From a25a5e6ba0751c1f6c17bbc4c99beac748644f7c Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Thu, 18 Feb 2021 14:09:35 -0800 Subject: [PATCH 1/5] Trim off the target branch --- .../get-markdown-files-from-changed-files.ps1 | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 6316fd1ce26e..7df115d87ee8 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,11 +2,15 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = "origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" + [string] $targetBranch = "${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" ) -$deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) -$renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) -$changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') + +# Trim the "ref/head" for master branch +$targetBranch = $targetBranch -replace "refs/heads/" + +$deletedFiles = (git diff "origin/$targetBranch" HEAD --name-only --diff-filter=D) +$renamedFiles = (git diff "origin/$targetBranch" HEAD --diff-filter=R) +$changedMarkdowns = (git diff "origin/$targetBranch" HEAD --name-only -- '*.md') $beforeRenameFiles = @() # Retrieve the 'renamed from' files. Git command only returns back the files after rename. From ca70536302af00a5cd7775d4da4feb45652a057b Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:26:38 -0800 Subject: [PATCH 2/5] Update eng/common/scripts/get-markdown-files-from-changed-files.ps1 Co-authored-by: Wes Haggard --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 7df115d87ee8..d50e7edb7f8f 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,7 +2,7 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = "${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" + [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) # Trim the "ref/head" for master branch From 669cb79ddcde421efff45fc5c720e783bda4ef14 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:36:38 -0800 Subject: [PATCH 3/5] Update get-markdown-files-from-changed-files.ps1 --- .../scripts/get-markdown-files-from-changed-files.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index d50e7edb7f8f..5fd1ed0ac7e5 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -5,12 +5,9 @@ param ( [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) -# Trim the "ref/head" for master branch -$targetBranch = $targetBranch -replace "refs/heads/" - -$deletedFiles = (git diff "origin/$targetBranch" HEAD --name-only --diff-filter=D) -$renamedFiles = (git diff "origin/$targetBranch" HEAD --diff-filter=R) -$changedMarkdowns = (git diff "origin/$targetBranch" HEAD --name-only -- '*.md') +$deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) +$renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) +$changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') $beforeRenameFiles = @() # Retrieve the 'renamed from' files. Git command only returns back the files after rename. From 729d497a07f56ed8523541da8bcb81612723ac84 Mon Sep 17 00:00:00 2001 From: Sima Zhu <48036328+sima-zhu@users.noreply.github.com> Date: Thu, 18 Feb 2021 15:36:56 -0800 Subject: [PATCH 4/5] Update get-markdown-files-from-changed-files.ps1 --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 5fd1ed0ac7e5..84455e5ff1e4 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -4,7 +4,6 @@ param ( # The target branch to compare with. [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") ) - $deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) $renamedFiles = (git diff $targetBranch HEAD --diff-filter=R) $changedMarkdowns = (git diff $targetBranch HEAD --name-only -- '*.md') From c880dbe2a319c44463599cd4e021f5e70c573328 Mon Sep 17 00:00:00 2001 From: Sima Zhu Date: Fri, 19 Feb 2021 10:40:57 -0800 Subject: [PATCH 5/5] Trim the slash --- eng/common/scripts/get-markdown-files-from-changed-files.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 index 84455e5ff1e4..4e0d48bb87e4 100644 --- a/eng/common/scripts/get-markdown-files-from-changed-files.ps1 +++ b/eng/common/scripts/get-markdown-files-from-changed-files.ps1 @@ -2,7 +2,7 @@ param ( # The root repo we scaned with. [string] $RootRepo = '$PSScriptRoot/../../..', # The target branch to compare with. - [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") + [string] $targetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "/refs/heads/") ) $deletedFiles = (git diff $targetBranch HEAD --name-only --diff-filter=D) $renamedFiles = (git diff $targetBranch HEAD --diff-filter=R)