This repository has been archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 138
Mlonis fix for issue 165 #555
Open
mrlonis
wants to merge
4
commits into
PowerShell:development
Choose a base branch
from
mrlonis:mlonis-fix-for-issue-165
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -396,13 +396,23 @@ function Update-ScriptFileInfo { | |
$PSScriptInfoString = $PSScriptInfoString.TrimStart() | ||
$requiresStrings = $requiresStrings.TrimEnd() | ||
|
||
$tempContents += "$PSScriptInfoString `r`n`r`n$($requiresStrings -join "`r`n")" | ||
if ($requiresStrings.Trim() -ne "") { | ||
$tempContents += "$PSScriptInfoString`r`n`r`n$($requiresStrings -join "`r`n")" | ||
} else { | ||
$tempContents += $PSScriptInfoString | ||
} | ||
Comment on lines
+399
to
+403
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This resolves issue #165 by not adding extra newlines if the user did not supply any required modules. If the user does not supply any required modules, Get-RequiresString returns the empty string. |
||
$IsNewPScriptInfoAdded = $true | ||
} | ||
} | ||
elseif ($line -notmatch "\s*#Requires\s+-Module") { | ||
# Add the existing lines if they are not part of PSScriptInfo comment or not containing #Requires -Module statements. | ||
$tempContents += $line | ||
} elseif (($scriptFileContents[$i + 1] -eq "`r`n" -or $scriptFileContents[$i + 1] -eq "") -and (($i + 1) -lt $scriptFileContents.Count)) { | ||
# This condition will only be met if the line is a Requires -Module statement. | ||
# To adding newlines everytime the function is called on a script, we must increment i by 1 | ||
# if the next line after the caught Requires -Module statement is the empty string or a `r`n | ||
# This prevents extra newlines from being inserted | ||
$i = $i + 1 | ||
Comment on lines
+410
to
+415
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This section accounts for the edge case where a script file already has Requires -Module statements and prevents the addition of new lines by incrementing $i when it detects that the line following the last Requires -Modules statement is a character return newline sequence or the empty string. |
||
} | ||
} | ||
|
||
|
@@ -441,7 +451,7 @@ function Update-ScriptFileInfo { | |
|
||
if ($line.Trim().StartsWith("#>", [System.StringComparison]::OrdinalIgnoreCase) -or | ||
$line.Trim().StartsWith(".", [System.StringComparison]::OrdinalIgnoreCase)) { | ||
$tempContents += ".DESCRIPTION `r`n$($Description -join "`r`n")`r`n" | ||
$tempContents += ".DESCRIPTION`r`n$($Description -join "`r`n")`r`n" | ||
$IsDescriptionAdded = $true | ||
$tempContents += $line | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This simplifies the code into one line and further prevents the addition of a new line when the release notes section is being left blank or empty.