Skip to content

Commit 26a32ea

Browse files
obrockikatriendg
andauthored
feat(skills): enhance pr-reference skill with flexible filtering and base branch detection (#1095)
Enhanced the `pr-reference` skill with four new capabilities: automatic default branch detection, merge-base comparison, multi-type file filtering, and extension/path exclusion. All changes are mirrored across bash and PowerShell implementations with comprehensive Pester test coverage (95.9% line coverage for the package). ### Changes **`generate.sh` / `generate.ps1`:** - Added `--merge-base` / `-MergeBase` flag for three-way comparison via `git merge-base` instead of direct diff - Added `--base-branch auto` / `-BaseBranch auto` to detect the remote default branch via `git symbolic-ref refs/remotes/origin/HEAD` with `origin/main` fallback - Added `--exclude-ext` / `-ExcludeExt` for comma-separated file extension exclusion from diffs using git pathspec negation - Added `--exclude-path` / `-ExcludePath` for comma-separated path prefix exclusion from diffs **`list-changed-files.sh` / `list-changed-files.ps1`:** - Support comma-separated `--type` / `-Type` values (e.g., `--type added,modified,renamed`) - Added `--exclude-type` / `-ExcludeType` for inverse type filtering with mutual exclusion validation **`shared.psm1`:** - Added `Resolve-DefaultBranch` helper for auto-detecting the remote default branch - Added `Build-PathspecExclusions` helper for constructing git pathspec negation arrays from extensions and paths **`SKILL.md`:** - Updated Parameters Reference table with all new flags for both generate and list-changed-files scripts - Updated usage examples showing new capabilities **Pester Tests:** - Added test contexts for `-MergeBase`, `-BaseBranch auto`, `-ExcludeExt`, `-ExcludePath`, combined flags - Added test contexts for comma-separated `-Type`, `-ExcludeType`, mutual exclusion, invalid type validation - Added test contexts for `Resolve-DefaultBranch` (success + fallback) and `Build-PathspecExclusions` (extensions, paths, combined, edge cases) ## Related Issue(s) Closes #1011 ## Type of Change Select all that apply: **Code & Documentation:** * [ ] Bug fix (non-breaking change fixing an issue) * [x] New feature (non-breaking change adding functionality) * [ ] Breaking change (fix or feature causing existing functionality to change) * [x] Documentation update **Infrastructure & Configuration:** * [ ] GitHub Actions workflow * [ ] Linting configuration (markdown, PowerShell, etc.) * [ ] Security configuration * [ ] DevContainer configuration * [ ] Dependency update **AI Artifacts:** * [ ] Reviewed contribution with `prompt-builder` agent and addressed all feedback * [ ] Copilot instructions (`.github/instructions/*.instructions.md`) * [ ] Copilot prompt (`.github/prompts/*.prompt.md`) * [ ] Copilot agent (`.github/agents/*.agent.md`) * [x] Copilot skill (`.github/skills/*/SKILL.md`) > Note for AI Artifact Contributors: > > * Agents: Research, indexing/referencing other project (using standard VS Code GitHub Copilot/MCP tools), planning, and general implementation agents likely already exist. Review `.github/agents/` before creating new ones. > * Skills: Must include both bash and PowerShell scripts. See [Skills](../docs/contributing/skills.md). > * Model Versions: Only contributions targeting the **latest Anthropic and OpenAI models** will be accepted. Older model versions (e.g., GPT-3.5, Claude 3) will be rejected. > * See [Agents Not Accepted](../docs/contributing/custom-agents.md#agents-not-accepted) and [Model Version Requirements](../docs/contributing/ai-artifacts-common.md#model-version-requirements). **Other:** * [x] Script/automation (`.ps1`, `.sh`, `.py`) * [ ] Other (please describe): ## Sample Prompts (for AI Artifact Contributions) **User Request:** > Generate a PR reference excluding YAML files and using merge-base comparison **Execution Flow:** 1. Agent reads SKILL.md and identifies `generate.ps1` as the appropriate script 2. Calls `scripts/generate.ps1 -BaseBranch auto -MergeBase -ExcludeExt yml,yaml` 3. Script resolves the remote default branch via `git symbolic-ref refs/remotes/origin/HEAD` 4. Resolves merge-base between HEAD and the detected branch 5. Generates diff excluding `*.yml` and `*.yaml` files via pathspec negation 6. Writes XML output to `.copilot-tracking/pr/pr-reference.xml` **Output Artifacts:** - `.copilot-tracking/pr/pr-reference.xml` — structured XML with commit history and filtered diff **Success Indicators:** - Console output shows "Comparison mode: merge-base" and "Note: Extensions excluded from diff: yml, yaml" - XML output contains only non-YAML file diffs - Commit range uses merge-base commit SHA instead of direct branch ref ## Testing ### Pester Tests All 155 non-integration tests passed with 0 failures: ```json { "Timestamp": "2026-03-16T13:12:12.4376485+00:00", "Result": "Passed", "TotalCount": 180, "PassedCount": 155, "FailedCount": 0, "SkippedCount": 0, "Duration": "00:02:57.4373385", "CoveragePercent": 4.71 } ``` (25 integration-tagged tests excluded per default Pester filter configuration.) ### Code Coverage (pr-reference package) Coverage computed from JaCoCo report for the pr-reference scripts package: | Script | Line Coverage | |--------------------|---------------| | generate.ps1 | 136/142 = 95.8% | | list-changed-files.ps1 | 63/67 = 94.0% | | read-diff.ps1 | 101/105 = 96.2% | | shared.psm1 | 24/24 = 100.0% | | **Package total** | **324/338 = 95.9%** | ### shellcheck Both bash scripts pass with zero warnings: ``` shellcheck .github/skills/shared/pr-reference/scripts/generate.sh .github/skills/shared/pr-reference/scripts/list-changed-files.sh # Exit code: 0, no output ``` ### PSScriptAnalyzer All PowerShell scripts pass with zero violations: ``` Invoke-ScriptAnalyzer -Path '.github/skills/shared/pr-reference/scripts/' -Recurse # 0 violations ``` ### Skill Structure Validation ``` npm run validate:skills # ✅ pr-reference — passed ``` ### Plugin Generation & Validation ``` npm run plugin:generate # 11 plugin(s) generated, 0 errors npm run plugin:validate # 11 collections validated, 0 errors ``` ### Manual Testing - [ ] Manually test calling the skill with the newer parameters and validate the correct scripts execute the required git commands ## Checklist ### Required Checks * [x] Documentation is updated (if applicable) * [x] Files follow existing naming conventions * [x] Changes are backwards compatible (if applicable) * [x] Tests added for new functionality (if applicable) ### AI Artifact Contributions <!-- If contributing an agent, prompt, instruction, or skill, complete these checks --> * [ ] Used `/prompt-analyze` to review contribution * [ ] Addressed all feedback from `prompt-builder` review * [ ] Verified contribution follows common standards and type-specific requirements ### Required Automated Checks The following validation commands must pass before merging: * [x] Markdown linting: `npm run lint:md` * [x] Spell checking: `npm run spell-check` * [x] Frontmatter validation: `npm run lint:frontmatter` * [x] Skill structure validation: `npm run validate:skills` * [x] Link validation: `npm run lint:md-links` * [x] PowerShell analysis: `npm run lint:ps` * [x] Plugin freshness: `npm run plugin:generate` ## Security Considerations <!-- ⚠️ WARNING: Do not commit sensitive information such as API keys, passwords, or personal data --> * [x] This PR does not contain any sensitive or NDA information * [x] Any new dependencies have been reviewed for security issues (N/A — no new dependencies) * [x] Security-related scripts follow the principle of least privilege (N/A — no security script changes) ## Additional Notes - The `--no-md-diff` / `-ExcludeMarkdownDiff` flag is preserved for backward compatibility. The new `--exclude-ext md` achieves the same result. - Collection manifests were not updated because no skill paths changed — only internal file contents were modified. - The `CoveragePercent: 4.71` in the Pester summary is the **overall project** coverage. The pr-reference **package-specific** coverage is 95.9% as shown in the JaCoCo breakdown above. --------- Co-authored-by: Katrien De Graeve <katriendg@users.noreply.github.com>
1 parent e49a1b5 commit 26a32ea

File tree

12 files changed

+845
-82
lines changed

12 files changed

+845
-82
lines changed

.github/skills/shared/pr-reference/SKILL.md

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
name: pr-reference
3-
description: 'Generates PR reference XML containing commit history and unified diffs between branches. Includes utilities to list changed files and read diff chunks. Use when creating pull request descriptions, preparing code reviews, analyzing branch changes, discovering work items from diffs, or generating structured diff summaries. - Brought to you by microsoft/hve-core'
3+
description: 'Generates PR reference XML containing commit history and unified diffs between branches with extension and path filtering. Includes utilities to list changed files by type and read diff chunks. Use when creating pull request descriptions, preparing code reviews, analyzing branch changes, discovering work items from diffs, or generating structured diff summaries. - Brought to you by microsoft/hve-core'
44
user-invocable: true
55
compatibility: 'Requires git available on PATH'
66
---
@@ -25,7 +25,7 @@ After successful generation, include a file link to the absolute path of the XML
2525
The repository must have at least one commit diverging from the base branch.
2626

2727
| Platform | Runtime |
28-
| -------------- | -------------------- |
28+
|----------------|----------------------|
2929
| macOS / Linux | Bash (pre-installed) |
3030
| Windows | PowerShell 7+ (pwsh) |
3131
| Cross-platform | PowerShell 7+ (pwsh) |
@@ -36,21 +36,26 @@ Run the following command to generate a PR reference with default settings (comp
3636

3737
```bash
3838
scripts/generate.sh
39+
scripts/generate.sh --base-branch auto --merge-base --exclude-ext yml,json
3940
```
4041

4142
```powershell
4243
scripts/generate.ps1
44+
scripts/generate.ps1 -BaseBranch auto -MergeBase -ExcludeExt yml,json
4345
```
4446

4547
Output saves to `.copilot-tracking/pr/pr-reference.xml` by default.
4648

4749
## Parameters Reference
4850

49-
| Parameter | Flag (bash) | Flag (PowerShell) | Default | Description |
50-
| ---------------- | --------------- | ---------------------- | ------------------------------------------ | ------------------------------------------- |
51-
| Base branch | `--base-branch` | `-BaseBranch` | `origin/main` (bash) / `main` (PowerShell) | Target branch for comparison |
52-
| Exclude markdown | `--no-md-diff` | `-ExcludeMarkdownDiff` | false | Exclude markdown files (*.md) from the diff |
53-
| Output path | `--output` | `-OutputPath` | `.copilot-tracking/pr/pr-reference.xml` | Custom output file path |
51+
| Parameter | Flag (bash) | Flag (PowerShell) | Default | Description |
52+
|--------------------|------------------|------------------------|--------------------------------------------|--------------------------------------------------------------------|
53+
| Base branch | `--base-branch` | `-BaseBranch` | `origin/main` (bash) / `main` (PowerShell) | Target branch for comparison. Use `auto` to detect remote default. |
54+
| Merge base | `--merge-base` | `-MergeBase` | false | Use `git merge-base` for three-way comparison |
55+
| Exclude markdown | `--no-md-diff` | `-ExcludeMarkdownDiff` | false | Exclude markdown files (*.md) from the diff |
56+
| Exclude extensions | `--exclude-ext` | `-ExcludeExt` | (none) | Comma-separated extensions to exclude (e.g., `yml,yaml,json,png`) |
57+
| Exclude paths | `--exclude-path` | `-ExcludePath` | (none) | Comma-separated path prefixes to exclude (e.g., `docs/,.github/`) |
58+
| Output path | `--output` | `-OutputPath` | `.copilot-tracking/pr/pr-reference.xml` | Custom output file path |
5459

5560
Both defaults resolve to the same remote comparison. The PowerShell script automatically resolves `origin/<branch>` when a bare branch name is provided.
5661

@@ -63,17 +68,28 @@ After generating the PR reference, use these utility scripts to query the XML.
6368
Run the list script to extract file paths from the diff:
6469

6570
```bash
66-
scripts/list-changed-files.sh # all changed files
67-
scripts/list-changed-files.sh --type added # filter by change type
68-
scripts/list-changed-files.sh --format markdown # output as markdown table
71+
scripts/list-changed-files.sh # all changed files
72+
scripts/list-changed-files.sh --type added # filter by single type
73+
scripts/list-changed-files.sh --type added,modified,renamed # filter by multiple types
74+
scripts/list-changed-files.sh --exclude-type deleted # exclude specific types
75+
scripts/list-changed-files.sh --format markdown # output as markdown table
6976
```
7077

7178
```powershell
72-
scripts/list-changed-files.ps1 # all changed files
73-
scripts/list-changed-files.ps1 -Type Added # filter by change type
74-
scripts/list-changed-files.ps1 -Format Json # output as JSON
79+
scripts/list-changed-files.ps1 # all changed files
80+
scripts/list-changed-files.ps1 -Type Added # filter by single type
81+
scripts/list-changed-files.ps1 -Type Added,Modified,Renamed # filter by multiple types
82+
scripts/list-changed-files.ps1 -ExcludeType Deleted # exclude specific types
83+
scripts/list-changed-files.ps1 -Format Json # output as JSON
7584
```
7685

86+
| Parameter | Flag (bash) | Flag (PowerShell) | Default | Description |
87+
|--------------|------------------|-------------------|---------|-----------------------------------------------------------------------|
88+
| Input path | `--input`, `-i` | `-InputPath` | (auto) | Path to pr-reference.xml |
89+
| Type filter | `--type`, `-t` | `-Type` | `all` | Change types to include (comma-separated: added, modified, etc.) |
90+
| Exclude type | `--exclude-type` | `-ExcludeType` | (none) | Change types to exclude. Mutually exclusive with `--type` (non-`all`) |
91+
| Format | `--format`, `-f` | `-Format` | `plain` | Output format: plain, json, or markdown |
92+
7793
### Read Diff Content
7894

7995
Run the read script to inspect diff content with chunking for large diffs:
@@ -97,10 +113,10 @@ The generated XML wraps commit metadata and unified diff output in a `<commit_hi
97113

98114
## Troubleshooting
99115

100-
| Symptom | Cause | Resolution |
101-
| -------------------------------- | ------------------------------------ | ------------------------------------------------------------------------ |
102-
| "No commits found" or empty XML | No diverging commits from base branch | Verify the branch has commits ahead of the base with `git log base..HEAD` |
103-
| "Branch not found" error | Base branch ref missing locally | Run `git fetch origin` to update remote tracking refs |
104-
| "git: command not found" | git is not on PATH | Install git or verify PATH includes the git binary directory |
116+
| Symptom | Cause | Resolution |
117+
|---------------------------------|---------------------------------------|---------------------------------------------------------------------------|
118+
| "No commits found" or empty XML | No diverging commits from base branch | Verify the branch has commits ahead of the base with `git log base..HEAD` |
119+
| "Branch not found" error | Base branch ref missing locally | Run `git fetch origin` to update remote tracking refs |
120+
| "git: command not found" | git is not on PATH | Install git or verify PATH includes the git binary directory |
105121

106122
*🤖 Crafted with precision by ✨Copilot following brilliant human instruction, then carefully refined by our team of discerning human reviewers.*

.github/skills/shared/pr-reference/scripts/generate.ps1

Lines changed: 130 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,23 @@ for comparisons.
1414
1515
.PARAMETER BaseBranch
1616
Git branch used as the comparison base. Defaults to "main".
17+
Use "auto" to detect the remote default branch.
18+
19+
.PARAMETER MergeBase
20+
When supplied, uses git merge-base for three-way comparison instead of
21+
direct diff against the base branch.
1722
1823
.PARAMETER ExcludeMarkdownDiff
1924
When supplied, excludes markdown (*.md) files from the diff output.
2025
26+
.PARAMETER ExcludeExt
27+
Comma-separated or array of file extensions to exclude from the diff
28+
(e.g., 'yml,yaml,json'). Leading dots are stripped automatically.
29+
30+
.PARAMETER ExcludePath
31+
Comma-separated or array of path prefixes to exclude from the diff
32+
(e.g., 'docs/,.github/skills/').
33+
2134
.PARAMETER OutputPath
2235
Custom output file path. When empty, defaults to
2336
.copilot-tracking/pr/pr-reference.xml relative to the repository root.
@@ -28,9 +41,18 @@ param(
2841
[Parameter()]
2942
[string]$BaseBranch = "main",
3043

44+
[Parameter()]
45+
[switch]$MergeBase,
46+
3147
[Parameter()]
3248
[switch]$ExcludeMarkdownDiff,
3349

50+
[Parameter()]
51+
[string[]]$ExcludeExt = @(),
52+
53+
[Parameter()]
54+
[string[]]$ExcludePath = @(),
55+
3456
[Parameter()]
3557
[string]$OutputPath = ""
3658
)
@@ -88,15 +110,21 @@ function Resolve-ComparisonReference {
88110
Resolves the git reference used for comparisons.
89111
.DESCRIPTION
90112
Prefers origin/<BaseBranch> when available and falls back to the provided branch.
113+
When UseMergeBase is set, resolves the merge-base between HEAD and the branch.
91114
.PARAMETER BaseBranch
92115
Branch name supplied by the caller.
116+
.PARAMETER UseMergeBase
117+
When set, resolves the merge-base commit instead of using the branch directly.
93118
.OUTPUTS
94119
PSCustomObject
95120
#>
96121
[OutputType([PSCustomObject])]
97122
param(
98123
[Parameter(Mandatory = $true)]
99-
[string]$BaseBranch
124+
[string]$BaseBranch,
125+
126+
[Parameter()]
127+
[switch]$UseMergeBase
100128
)
101129

102130
$candidates = @()
@@ -105,23 +133,40 @@ PSCustomObject
105133
}
106134
$candidates += $BaseBranch
107135

136+
$resolvedRef = $null
137+
$resolvedCandidate = $null
108138
foreach ($candidate in $candidates) {
109139
& git rev-parse --verify $candidate *> $null
110140
if ($LASTEXITCODE -eq 0) {
111-
$label = if ($candidate -eq $BaseBranch) {
112-
$BaseBranch
113-
} else {
114-
"$BaseBranch (via $candidate)"
115-
}
116-
117-
return [PSCustomObject]@{
118-
Ref = $candidate
119-
Label = $label
120-
}
141+
$resolvedRef = $candidate
142+
$resolvedCandidate = $candidate
143+
break
121144
}
122145
}
123146

124-
throw "Branch '$BaseBranch' does not exist or is not accessible."
147+
if (-not $resolvedRef) {
148+
throw "Branch '$BaseBranch' does not exist or is not accessible."
149+
}
150+
151+
if ($UseMergeBase) {
152+
$mb = (& git merge-base HEAD $resolvedRef 2>$null)
153+
if ($LASTEXITCODE -eq 0 -and $mb) {
154+
$resolvedRef = $mb.Trim()
155+
} else {
156+
Write-Warning "merge-base resolution failed, using direct comparison"
157+
}
158+
}
159+
160+
$label = if ($resolvedCandidate -eq $BaseBranch) {
161+
$BaseBranch
162+
} else {
163+
"$BaseBranch (via $resolvedCandidate)"
164+
}
165+
166+
return [PSCustomObject]@{
167+
Ref = $resolvedRef
168+
Label = $label
169+
}
125170
}
126171

127172
function Get-ShortCommitHash {
@@ -244,11 +289,15 @@ function Get-DiffOutput {
244289
.SYNOPSIS
245290
Builds the git diff output for the comparison ref.
246291
.DESCRIPTION
247-
Runs git diff against the comparison ref with optional markdown exclusion.
292+
Runs git diff against the comparison ref with optional file exclusions.
248293
.PARAMETER ComparisonRef
249294
Git reference that acts as the diff base.
250295
.PARAMETER ExcludeMarkdownDiff
251296
Switch to omit markdown files from the diff.
297+
.PARAMETER ExcludeExt
298+
File extensions to exclude from the diff.
299+
.PARAMETER ExcludePath
300+
Path prefixes to exclude from the diff.
252301
.OUTPUTS
253302
System.String[]
254303
#>
@@ -258,12 +307,25 @@ System.String[]
258307
[string]$ComparisonRef,
259308

260309
[Parameter()]
261-
[switch]$ExcludeMarkdownDiff
310+
[switch]$ExcludeMarkdownDiff,
311+
312+
[Parameter()]
313+
[string[]]$ExcludeExt = @(),
314+
315+
[Parameter()]
316+
[string[]]$ExcludePath = @()
262317
)
263318

264319
$diffArgs = @('--no-pager', 'diff', $ComparisonRef)
320+
321+
$pathspecs = @()
265322
if ($ExcludeMarkdownDiff) {
266-
$diffArgs += @('--', ':!*.md')
323+
$pathspecs += ':!*.md'
324+
}
325+
$pathspecs += Build-PathspecExclusions -Extensions $ExcludeExt -Paths $ExcludePath
326+
if ($pathspecs.Count -gt 0) {
327+
$diffArgs += '--'
328+
$diffArgs += $pathspecs
267329
}
268330

269331
$diffOutput = & git @diffArgs
@@ -284,6 +346,10 @@ Uses git diff --shortstat against the comparison ref.
284346
Git reference that acts as the diff base.
285347
.PARAMETER ExcludeMarkdownDiff
286348
Switch to omit markdown files from the summary.
349+
.PARAMETER ExcludeExt
350+
File extensions to exclude from the summary.
351+
.PARAMETER ExcludePath
352+
Path prefixes to exclude from the summary.
287353
.OUTPUTS
288354
System.String
289355
#>
@@ -293,12 +359,25 @@ System.String
293359
[string]$ComparisonRef,
294360

295361
[Parameter()]
296-
[switch]$ExcludeMarkdownDiff
362+
[switch]$ExcludeMarkdownDiff,
363+
364+
[Parameter()]
365+
[string[]]$ExcludeExt = @(),
366+
367+
[Parameter()]
368+
[string[]]$ExcludePath = @()
297369
)
298370

299371
$diffStatArgs = @('--no-pager', 'diff', '--shortstat', $ComparisonRef)
372+
373+
$pathspecs = @()
300374
if ($ExcludeMarkdownDiff) {
301-
$diffStatArgs += @('--', ':!*.md')
375+
$pathspecs += ':!*.md'
376+
}
377+
$pathspecs += Build-PathspecExclusions -Extensions $ExcludeExt -Paths $ExcludePath
378+
if ($pathspecs.Count -gt 0) {
379+
$diffStatArgs += '--'
380+
$diffStatArgs += $pathspecs
302381
}
303382

304383
$summary = & git @diffStatArgs
@@ -413,9 +492,15 @@ Generates the pr-reference.xml file.
413492
.DESCRIPTION
414493
Coordinates git queries, XML creation, and console reporting for Copilot usage.
415494
.PARAMETER BaseBranch
416-
Branch used as the comparison base.
495+
Branch used as the comparison base. Use 'auto' to detect the remote default.
496+
.PARAMETER MergeBase
497+
When supplied, uses git merge-base for three-way comparison.
417498
.PARAMETER ExcludeMarkdownDiff
418499
Switch to omit markdown files from the diff and summary.
500+
.PARAMETER ExcludeExt
501+
File extensions to exclude from the diff.
502+
.PARAMETER ExcludePath
503+
Path prefixes to exclude from the diff.
419504
.PARAMETER OutputPath
420505
Custom output file path. When empty, defaults to
421506
.copilot-tracking/pr/pr-reference.xml relative to the repository root.
@@ -427,9 +512,18 @@ System.IO.FileInfo
427512
[Parameter(Mandatory = $true)]
428513
[string]$BaseBranch,
429514

515+
[Parameter()]
516+
[switch]$MergeBase,
517+
430518
[Parameter()]
431519
[switch]$ExcludeMarkdownDiff,
432520

521+
[Parameter()]
522+
[string[]]$ExcludeExt = @(),
523+
524+
[Parameter()]
525+
[string[]]$ExcludePath = @(),
526+
433527
[Parameter()]
434528
[string]$OutputPath = ""
435529
)
@@ -438,6 +532,11 @@ System.IO.FileInfo
438532

439533
$repoRoot = Get-RepositoryRoot -Strict
440534

535+
# Resolve auto base branch
536+
if ($BaseBranch -eq 'auto') {
537+
$BaseBranch = Resolve-DefaultBranch
538+
}
539+
441540
if ($OutputPath) {
442541
$prReferencePath = $OutputPath
443542
} else {
@@ -454,12 +553,12 @@ System.IO.FileInfo
454553
Push-Location $repoRoot
455554
try {
456555
$currentBranch = Get-CurrentBranchOrRef
457-
$comparisonInfo = Resolve-ComparisonReference -BaseBranch $BaseBranch
556+
$comparisonInfo = Resolve-ComparisonReference -BaseBranch $BaseBranch -UseMergeBase:$MergeBase
458557
$baseCommit = Get-ShortCommitHash -Ref $comparisonInfo.Ref
459558
$commitEntries = Get-CommitEntry -ComparisonRef $comparisonInfo.Ref
460559
$commitCount = Get-CommitCount -ComparisonRef $comparisonInfo.Ref
461-
$diffOutput = Get-DiffOutput -ComparisonRef $comparisonInfo.Ref -ExcludeMarkdownDiff:$ExcludeMarkdownDiff
462-
$diffSummary = Get-DiffSummary -ComparisonRef $comparisonInfo.Ref -ExcludeMarkdownDiff:$ExcludeMarkdownDiff
560+
$diffOutput = Get-DiffOutput -ComparisonRef $comparisonInfo.Ref -ExcludeMarkdownDiff:$ExcludeMarkdownDiff -ExcludeExt $ExcludeExt -ExcludePath $ExcludePath
561+
$diffSummary = Get-DiffSummary -ComparisonRef $comparisonInfo.Ref -ExcludeMarkdownDiff:$ExcludeMarkdownDiff -ExcludeExt $ExcludeExt -ExcludePath $ExcludePath
463562

464563
$xmlContent = Get-PrXmlContent -CurrentBranch $currentBranch -BaseBranch $BaseBranch -CommitEntries $commitEntries -DiffOutput $diffOutput
465564
$xmlContent | Set-Content -LiteralPath $prReferencePath
@@ -475,6 +574,15 @@ System.IO.FileInfo
475574
if ($ExcludeMarkdownDiff) {
476575
Write-Host 'Note: Markdown files were excluded from diff output'
477576
}
577+
if ($ExcludeExt.Count -gt 0) {
578+
Write-Host "Note: Extensions excluded from diff: $($ExcludeExt -join ', ')"
579+
}
580+
if ($ExcludePath.Count -gt 0) {
581+
Write-Host "Note: Paths excluded from diff: $($ExcludePath -join ', ')"
582+
}
583+
if ($MergeBase) {
584+
Write-Host 'Comparison mode: merge-base'
585+
}
478586
Write-Host "Lines: $lineCount"
479587
Write-Host "Base branch: $($comparisonInfo.Label) (@ $baseCommit)"
480588
Write-Host "Commits compared: $commitCount"
@@ -490,7 +598,7 @@ System.IO.FileInfo
490598
#region Main Execution
491599
if ($MyInvocation.InvocationName -ne '.') {
492600
try {
493-
Invoke-PrReferenceGeneration -BaseBranch $BaseBranch -ExcludeMarkdownDiff:$ExcludeMarkdownDiff -OutputPath $OutputPath | Out-Null
601+
Invoke-PrReferenceGeneration -BaseBranch $BaseBranch -MergeBase:$MergeBase -ExcludeMarkdownDiff:$ExcludeMarkdownDiff -ExcludeExt $ExcludeExt -ExcludePath $ExcludePath -OutputPath $OutputPath | Out-Null
494602
exit 0
495603
}
496604
catch {

0 commit comments

Comments
 (0)