Skip to content

Commit

Permalink
feat: ugit action -NoCommit ( Fixes #318 )
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Oct 15, 2024
1 parent 13326c9 commit 90a784e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
11 changes: 8 additions & 3 deletions Build/GitHub/Actions/UGitAction.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ $UserEmail,
$UserName,

# If set, will not push any changes made to the repository.
# (they will still be committed unless -NoCommit is passed)
# (they will still be committed unless `-NoCommit` is passed)
[switch]
$NoPush
$NoPush,

# If set, will not commit any changes made to the repository.
# (this also implies `-NoPush`)
[switch]
$NoCommit
)

$ErrorActionPreference = 'continue'
Expand Down Expand Up @@ -309,7 +314,7 @@ filter ProcessOutput {
} elseif ($outItem) {
$outItem.FullName, (git status $outItem.Fullname -s)
}
if ($shouldCommit) {
if ($shouldCommit -and -not $NoCommit) {
"$fullName has changed, and should be committed" | Out-Host
git add $fullName
if ($out.Message) {
Expand Down
21 changes: 17 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ inputs:
required: false
description: |
If set, will not push any changes made to the repository.
(they will still be committed unless -NoCommit is passed)
(they will still be committed unless `-NoCommit` is passed)
NoCommit:
required: false
description: |
If set, will not commit any changes made to the repository.
(this also implies `-NoPush`)
branding:
icon: git-merge
color: blue
Expand All @@ -60,6 +65,7 @@ runs:
ActionScript: ${{inputs.ActionScript}}
TargetBranch: ${{inputs.TargetBranch}}
UserEmail: ${{inputs.UserEmail}}
NoCommit: ${{inputs.NoCommit}}
UserName: ${{inputs.UserName}}
run: |
$Parameters = @{}
Expand All @@ -77,6 +83,8 @@ runs:
$Parameters.UserName = ${env:UserName}
$Parameters.NoPush = ${env:NoPush}
$Parameters.NoPush = $parameters.NoPush -match 'true';
$Parameters.NoCommit = ${env:NoCommit}
$Parameters.NoCommit = $parameters.NoCommit -match 'true';
foreach ($k in @($parameters.Keys)) {
if ([String]::IsNullOrEmpty($parameters[$k])) {
$parameters.Remove($k)
Expand Down Expand Up @@ -141,9 +149,14 @@ runs:
$UserName,
# If set, will not push any changes made to the repository.
# (they will still be committed unless -NoCommit is passed)
# (they will still be committed unless `-NoCommit` is passed)
[switch]
$NoPush,
# If set, will not commit any changes made to the repository.
# (this also implies `-NoPush`)
[switch]
$NoPush
$NoCommit
)
$ErrorActionPreference = 'continue'
Expand Down Expand Up @@ -394,7 +407,7 @@ runs:
} elseif ($outItem) {
$outItem.FullName, (git status $outItem.Fullname -s)
}
if ($shouldCommit) {
if ($shouldCommit -and -not $NoCommit) {
"$fullName has changed, and should be committed" | Out-Host
git add $fullName
if ($out.Message) {
Expand Down

0 comments on commit 90a784e

Please sign in to comment.