Skip to content

Conversation

@KCoderVA
Copy link
Owner

This pull request updates the repository to improve license header automation, metadata handling, and documentation clarity. The main focus is on making the license header script more flexible and generic so it can be reused across projects and by different users, while also cleaning up and streamlining the setup guide.

License Header Automation Improvements:

  • The Add-LicenseHeaders.ps1 script now supports additional file types (md, txt, bat, psm, json) and allows users to inject custom metadata such as author name, email, organization, team, project name, license type, and compliance note. Metadata is auto-detected from Git config or environment variables if not provided. [1] [2]
  • License header templates have been refactored to use generic placeholders populated with user/project metadata, replacing hardcoded references to the original author and organization. The script now marks generated headers for easier identification.
  • The logic for detecting existing headers has been updated to look for generic indicators rather than specific author/organization names, reducing false positives and making the script more broadly applicable.
  • Logging in the header script now reflects the actual metadata used for each run, improving traceability and clarity.
  • File discovery in the header script is more robust, properly handling cases where no files are found for a given extension.

Documentation and Setup Guide Updates:

  • The README.md has been cleaned up to remove hardcoded copyright/license blocks, clarify the quick start and local setup instructions, and streamline guidance for accessing the interactive and printable guides. [1] [2] [3] [4]

Versioning:

  • The license header script version has been bumped to 1.0.1 to reflect these improvements.

README.md was streamlined for clarity, removing redundant sections and updating setup instructions. Add-LicenseHeaders.ps1 now supports more file types, auto-detects author metadata from Git config, and generates dynamic license headers with customizable fields. Header detection logic was improved for broader compatibility.
@KCoderVA KCoderVA requested a review from Copilot August 29, 2025 05:23
Copilot

This comment was marked as outdated.

KCoderVA and others added 2 commits August 29, 2025 01:25
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@KCoderVA KCoderVA merged commit 1601cf5 into main Aug 29, 2025
@KCoderVA KCoderVA self-assigned this Aug 29, 2025
@KCoderVA KCoderVA requested a review from Copilot August 29, 2025 05:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the license header automation script to be more generic and reusable while cleaning up the documentation. The main goal is to remove hardcoded author/organization references and make the tooling applicable across different projects and users.

  • Enhanced Add-LicenseHeaders.ps1 with parameterized metadata injection and auto-detection from Git config
  • Updated license header templates to use generic placeholders instead of hardcoded VA-specific information
  • Cleaned up README.md by removing hardcoded copyright blocks and streamlining setup instructions

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
copilot-instructions/Add-LicenseHeaders.ps1 Added metadata parameters, auto-detection logic, and genericized license templates
README.md Removed hardcoded copyright header and simplified quick start instructions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +107 to +114
# Auto-detect metadata if not provided
if (-not $AuthorName -or [string]::IsNullOrWhiteSpace($AuthorName)) { $AuthorName = (Get-GitConfigValue 'user.name'); if (-not $AuthorName) { $AuthorName = $env:USERNAME } }
if (-not $Email -or [string]::IsNullOrWhiteSpace($Email)) { $Email = (Get-GitConfigValue 'user.email'); if (-not $Email) { $Email = '' } }
if (-not $Organization) { $Organization = '' }
if (-not $Team) { $Team = '' }
if (-not $ProjectName -or [string]::IsNullOrWhiteSpace($ProjectName)) { $ProjectName = Split-Path -Leaf (Split-Path -Parent $ScriptPath) }
if (-not $LicenseType) { $LicenseType = 'Apache-2.0' }
if (-not $ComplianceNote) { $ComplianceNote = 'Internal Use Only' }
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These auto-detection lines are difficult to read and maintain due to complex nested conditionals on single lines. Consider refactoring into a helper function or breaking into multiple lines for better readability.

Suggested change
# Auto-detect metadata if not provided
if (-not $AuthorName -or [string]::IsNullOrWhiteSpace($AuthorName)) { $AuthorName = (Get-GitConfigValue 'user.name'); if (-not $AuthorName) { $AuthorName = $env:USERNAME } }
if (-not $Email -or [string]::IsNullOrWhiteSpace($Email)) { $Email = (Get-GitConfigValue 'user.email'); if (-not $Email) { $Email = '' } }
if (-not $Organization) { $Organization = '' }
if (-not $Team) { $Team = '' }
if (-not $ProjectName -or [string]::IsNullOrWhiteSpace($ProjectName)) { $ProjectName = Split-Path -Leaf (Split-Path -Parent $ScriptPath) }
if (-not $LicenseType) { $LicenseType = 'Apache-2.0' }
if (-not $ComplianceNote) { $ComplianceNote = 'Internal Use Only' }
# Helper: Get metadata value with fallback logic
function Get-MetadataValue {
param(
[Parameter(Mandatory=$true)][string]$CurrentValue,
[Parameter(Mandatory=$true)][ScriptBlock]$Fallback
)
if (-not $CurrentValue -or [string]::IsNullOrWhiteSpace($CurrentValue)) {
return & $Fallback
}
return $CurrentValue
}
# Auto-detect metadata if not provided
$AuthorName = Get-MetadataValue $AuthorName {
$name = Get-GitConfigValue 'user.name'
if ($name) { return $name }
return $env:USERNAME
}
$Email = Get-MetadataValue $Email {
$email = Get-GitConfigValue 'user.email'
if ($email) { return $email }
return ''
}
$Organization = Get-MetadataValue $Organization { return '' }
$Team = Get-MetadataValue $Team { return '' }
$ProjectName = Get-MetadataValue $ProjectName { Split-Path -Leaf (Split-Path -Parent $ScriptPath) }
$LicenseType = Get-MetadataValue $LicenseType { return 'Apache-2.0' }
$ComplianceNote = Get-MetadataValue $ComplianceNote { return 'Internal Use Only' }

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +231
$ContentText -match '(^/\*.*?(Licensed under|Copyright).*?\*/)' -or # block comment with license
$ContentText -match '(^<#.*?(Licensed under|Copyright).*?#>)' # ps1 block comment with license
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex patterns use ^ anchor which matches start of string, but $ContentText is a multiline string joined with newlines. These patterns will only match if the license header is at the very beginning of the file. Consider using multiline mode (?m)^ or \n to match line starts within the content.

Suggested change
$ContentText -match '(^/\*.*?(Licensed under|Copyright).*?\*/)' -or # block comment with license
$ContentText -match '(^<#.*?(Licensed under|Copyright).*?#>)' # ps1 block comment with license
$ContentText -match '(?m)^/\*.*?(Licensed under|Copyright).*?\*/' -or # block comment with license
$ContentText -match '(?m)^<#.*?(Licensed under|Copyright).*?#>' # ps1 block comment with license

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant