oc-harness-setup 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/unwired-routing.md +14 -9
- package/.gitignore +14 -1
- package/AGENTS.md +70 -106
- package/README.md +27 -23
- package/agents/build.md +10 -12
- package/agents/explore.md +14 -8
- package/agents/general.md +7 -9
- package/agents/orchestrator.md +38 -0
- package/agents/plan.md +10 -13
- package/agents/reviewer.md +9 -14
- package/agents/vault.md +44 -35
- package/bin/cli.js +32 -3
- package/commands/build.md +2 -8
- package/commands/checkpoint.md +3 -1
- package/commands/code-simplify.md +3 -9
- package/commands/gauntlet.md +7 -0
- package/commands/handoff.md +3 -1
- package/commands/keeper.md +3 -3
- package/commands/kill.md +11 -0
- package/commands/plan.md +2 -13
- package/commands/retro.md +15 -0
- package/commands/review.md +1 -1
- package/commands/ship.md +3 -27
- package/commands/spec.md +3 -11
- package/commands/test.md +2 -9
- package/commands/webperf.md +7 -0
- package/opencode.jsonc +23 -8
- package/package.json +3 -3
- package/reference/README.md +14 -14
- package/reference/auto-mandate.md +11 -0
- package/reference/backup-convention.md +9 -0
- package/reference/clean-mandate.md +13 -0
- package/reference/editor-parity.md +7 -0
- package/reference/gc-scripts.md +8 -0
- package/reference/intent-routing.md +14 -0
- package/reference/lifecycle.md +15 -0
- package/reference/model-keeper.md +30 -10
- package/reference/model-test.md +11 -6
- package/reference/models.md +25 -14
- package/reference/oc-source-map.md +162 -0
- package/reference/owner-pin.md +31 -0
- package/reference/roster.md +15 -0
- package/reference/session-scope.md +9 -0
- package/reference/session-state.md +13 -0
- package/reference/swarm.md +32 -0
- package/scripts/backup-config.ps1 +42 -0
- package/scripts/gc-branch.ps1 +196 -0
- package/scripts/gc-bump.ps1 +198 -0
- package/scripts/gc-clean.ps1 +648 -0
- package/scripts/gc-commit.ps1 +143 -0
- package/scripts/gc-merge.ps1 +272 -0
- package/scripts/gc-pr.ps1 +190 -0
- package/scripts/gc-push.ps1 +111 -0
- package/scripts/gc-read.ps1 +150 -0
- package/scripts/gc-rebase.ps1 +162 -0
- package/scripts/gc-release.ps1 +225 -0
- package/scripts/gc-stage.ps1 +103 -0
- package/scripts/gc-status.ps1 +127 -0
- package/scripts/gc-sync.ps1 +65 -0
- package/scripts/gc.core.ps1 +715 -0
- package/scripts/gc.smoke.ps1 +779 -0
- package/scripts/harness-doctor.ps1 +11 -9
- package/scripts/interrupt-session.ps1 +65 -0
- package/scripts/logbook/README.md +108 -0
- package/scripts/logbook/logbook.test.ts +440 -0
- package/scripts/logbook/logbook.ts +797 -0
- package/scripts/pirep/README.md +147 -0
- package/scripts/pirep/pirep.test.ts +735 -0
- package/scripts/pirep/pirep.ts +836 -0
- package/scripts/testflight/README.md +112 -0
- package/scripts/testflight/testflight.test.ts +512 -0
- package/scripts/testflight/testflight.ts +806 -0
- package/skills/_shared/SOURCES.md +7 -7
- package/skills/_shared/references/definition-of-done.md +2 -2
- package/skills/_shared/references/orchestration-patterns.md +1 -2
- package/skills/_shared/references/security-checklist.md +2 -2
- package/skills/api-and-interface-design/SKILL.md +7 -360
- package/skills/browser-testing-with-devtools/SKILL.md +303 -0
- package/skills/code-simplification/SKILL.md +7 -364
- package/skills/creative-writing/SKILL.md +1 -1
- package/skills/debugging-and-error-recovery/SKILL.md +8 -309
- package/skills/flight-deck/SKILL.md +17 -0
- package/skills/frontend-ui-engineering/SKILL.md +8 -320
- package/skills/gauntlet/SKILL.md +21 -0
- package/skills/git-ceremony/SKILL.md +16 -318
- package/skills/grilling/SKILL.md +10 -30
- package/skills/observability-and-instrumentation/SKILL.md +9 -229
- package/skills/performance-optimization/SKILL.md +8 -488
- package/skills/pilot-report/SKILL.md +18 -0
- package/skills/planning-and-task-breakdown/SKILL.md +8 -249
- package/skills/security-and-hardening/SKILL.md +9 -490
- package/skills/source-driven-development/SKILL.md +8 -208
- package/skills/spec-driven-development/SKILL.md +15 -234
- package/skills/test-driven-development/SKILL.md +8 -388
- package/skills/test-flight/SKILL.md +14 -0
- package/skills/writing-for-agents/SKILL-MECHANICS.md +3 -3
- package/skills/writing-for-agents/SKILL.md +7 -1
- package/agents/coder.md +0 -19
- package/agents/documenter.md +0 -28
- package/agents/keeper.md +0 -22
- package/agents/master.md +0 -70
- package/agents/researcher.md +0 -21
- package/agents/security-auditor.md +0 -20
- package/agents/test-engineer.md +0 -20
- package/agents/web-performance-auditor.md +0 -19
- package/commands/council.md +0 -24
- package/commands/doctor.md +0 -19
- package/commands/ponytail-audit.md +0 -7
- package/commands/ponytail-debt.md +0 -14
- package/commands/report.md +0 -13
- package/scripts/harness-report.ps1 +0 -695
- package/scripts/panic/panic.ts +0 -240
- package/skills/code-review-and-quality/SKILL.md +0 -396
- package/skills/incremental-implementation/SKILL.md +0 -249
- package/skills/swarm-orchestration/SKILL.md +0 -54
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
#Requires -Version 7.0
|
|
2
|
+
<#
|
|
3
|
+
.SYNOPSIS
|
|
4
|
+
Commit the staged content with a ceremony-validated message. No editor, no
|
|
5
|
+
prompts, no human in the middle.
|
|
6
|
+
|
|
7
|
+
.DESCRIPTION
|
|
8
|
+
git-ceremony §3 as a script. Validates the subject
|
|
9
|
+
(`type(scope): imperative summary`, ≤72 chars, no trailing period, lowercase
|
|
10
|
+
start — `fix: cap retry backoff at 30s`), caps the body at three plain
|
|
11
|
+
bullets, puts issue refs in the body (never the subject), refuses to commit
|
|
12
|
+
on every default-branch commit. Direct-default fallback is outside this
|
|
13
|
+
script only, after all §11b predicates are verified; unknown predicates
|
|
14
|
+
require stopping and escalating. Re-runs the secret
|
|
15
|
+
scan over the staged diff (the last gate), prints the staged diff stat for
|
|
16
|
+
review, then commits the staged content exactly.
|
|
17
|
+
|
|
18
|
+
Nothing staged fails with a remediation (run gc-stage or -All) — exit 2.
|
|
19
|
+
A repo without user.name/user.email fails with the fix — exit 2.
|
|
20
|
+
|
|
21
|
+
Repo rules win: if the repo documents its own convention (commit-lint,
|
|
22
|
+
sign-off, DCO), follow that instead of this script.
|
|
23
|
+
|
|
24
|
+
.PARAMETER Type
|
|
25
|
+
One of: feat, fix, chore, docs, refactor, test, perf, hotfix, wt.
|
|
26
|
+
.PARAMETER Scope
|
|
27
|
+
Optional kebab-case scope, e.g. api — renders as type(scope): summary.
|
|
28
|
+
.PARAMETER Summary
|
|
29
|
+
Imperative summary, lowercase first char, no trailing period.
|
|
30
|
+
.PARAMETER Body
|
|
31
|
+
Up to 3 plain lines; rendered as bullets under the subject. Bullets are
|
|
32
|
+
newline-separated: pwsh -File callers pass ONE argument with embedded `n
|
|
33
|
+
characters (repeated -Body and comma lists do NOT become arrays under
|
|
34
|
+
pwsh -File — a comma list lands as one literal bullet).
|
|
35
|
+
Do NOT prefix a body line with `-`: a leading dash collides with the
|
|
36
|
+
[string[]] binder and fails with the misleading "Missing an argument for
|
|
37
|
+
parameter 'Body'".
|
|
38
|
+
.PARAMETER Issue
|
|
39
|
+
Issue ref (#123 or ABC-123) — goes in the body, never the subject (§3).
|
|
40
|
+
.PARAMETER All
|
|
41
|
+
Stage everything first (git add -A, with the same gates as gc-stage).
|
|
42
|
+
.PARAMETER RepoRoot
|
|
43
|
+
Repository path (defaults to the current directory); git is always pinned
|
|
44
|
+
with git -C.
|
|
45
|
+
.PARAMETER Detailed
|
|
46
|
+
Restore the step narration, ok/info lines, git/gh relay, and the staged-diff
|
|
47
|
+
stat the terse default hides. Never affects the RESULT line, warnings,
|
|
48
|
+
failures, or the security/remediation lines.
|
|
49
|
+
.PARAMETER Quiet
|
|
50
|
+
Accepted for compatibility and now a no-op: the default is already terse.
|
|
51
|
+
-Quiet forces the gate closed and so wins if passed with -Detailed.
|
|
52
|
+
|
|
53
|
+
.EXAMPLE
|
|
54
|
+
pwsh -File scripts\gc-commit.ps1 -Type fix -Scope api -Summary 'cap retry backoff at 30s' `
|
|
55
|
+
-Body 'unbounded backoff stalled the queue ~9 min' -Issue #4821
|
|
56
|
+
#>
|
|
57
|
+
param(
|
|
58
|
+
[string]$Type,
|
|
59
|
+
[string]$Scope,
|
|
60
|
+
[Parameter(Mandatory)][string]$Summary,
|
|
61
|
+
[string[]]$Body,
|
|
62
|
+
[string]$Issue,
|
|
63
|
+
[switch]$All,
|
|
64
|
+
[string]$RepoRoot = (Get-Location).Path,
|
|
65
|
+
[switch]$Detailed,
|
|
66
|
+
[switch]$Quiet
|
|
67
|
+
)
|
|
68
|
+
Set-StrictMode -Version Latest
|
|
69
|
+
$ErrorActionPreference = 'Stop'
|
|
70
|
+
. (Join-Path $PSScriptRoot 'gc.core.ps1')
|
|
71
|
+
if ($Detailed) { $script:GcQuiet = $false }
|
|
72
|
+
if ($Quiet) { $script:GcQuiet = $true }
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
$root = Resolve-GcRoot -Path $RepoRoot
|
|
76
|
+
Write-GcInfo "repo: $root"
|
|
77
|
+
|
|
78
|
+
# branch only — targeted rev-parse; the cached state this would build is
|
|
79
|
+
# dropped by the `git add -A` below before Get-GcStagedNames reads it.
|
|
80
|
+
$cur = Get-GcCurrentBranch -Root $root -Targeted
|
|
81
|
+
$default = Get-GcDefaultBranch -Root $root
|
|
82
|
+
if ($cur -eq $default) {
|
|
83
|
+
throw [GcException]::new("intentionally refusing to commit on the default branch ($default). Direct-default fallback applies only when review state is absent (no remote collaborators, default-branch CI, branch protection, CODEOWNERS, or releases/tags), the change is R1 bounded/reversible/local, and gc-stage's secret gate has run. If every predicate is verified, documented §11b permits direct commit for snapshot/derived targets; see skills/git-ceremony §11b and reference/gc-scripts.md. If any condition is unknown or disputed, stop and escalate to the operator; do not retry with raw git.", $script:GcExitPre)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ($Scope -and $Scope -cnotmatch '^[a-z0-9-]+$') {
|
|
87
|
+
throw [GcException]::new("scope '$Scope' must be kebab-case — stray positional argument? pass every parameter by name", $script:GcExitPre)
|
|
88
|
+
}
|
|
89
|
+
$subject = if ($Scope) { "${Type}($Scope): $Summary" } else { "${Type}: $Summary" }
|
|
90
|
+
Write-GcInfo "subject: $subject"
|
|
91
|
+
$parts = Get-GcSubjectParts -Subject $subject # throws Pre with the fix on any violation
|
|
92
|
+
if ($parts.Summary -cmatch '#[0-9]+' -or $parts.Summary -cmatch '(?<![A-Za-z0-9])[A-Z]{3,}-[0-9]{2,}(?![A-Za-z0-9])') {
|
|
93
|
+
throw [GcException]::new("issue refs go in the body via -Issue, never the subject (§3) — '$($parts.Summary)' looks like a ref", $script:GcExitPre)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
$bullets = @()
|
|
97
|
+
foreach ($b in (@($Body) | ForEach-Object { $_ -split "`n" } | Where-Object { $_ -and $_.Trim() })) {
|
|
98
|
+
$bullets += ($b.Trim() -replace '^-+\s*','')
|
|
99
|
+
if ($bullets.Count -gt 3) {
|
|
100
|
+
throw [GcException]::new('body is capped at 3 plain bullets (§3)', $script:GcExitPre)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if ($Issue) {
|
|
104
|
+
if ($Issue -notmatch '^[A-Za-z0-9#_.-]+$') {
|
|
105
|
+
throw [GcException]::new("issue ref '$Issue' must be a bare ref like #123 or ABC-123", $script:GcExitPre)
|
|
106
|
+
}
|
|
107
|
+
$bullets += "refs $Issue"
|
|
108
|
+
if ($bullets.Count -gt 3) {
|
|
109
|
+
throw [GcException]::new('body plus issue ref is capped at 3 bullets (§3)', $script:GcExitPre)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Assert-GcIdentity -Root $root
|
|
114
|
+
|
|
115
|
+
if ($All) {
|
|
116
|
+
Invoke-GcGit -Root $root -Argv @('add','-A')
|
|
117
|
+
Write-GcOk 'staged all changes (-All)'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
# last gate: the staged diff (ceremony §3) — content plus secret scan
|
|
121
|
+
if (-not (Get-GcStagedNames -Root $root)) {
|
|
122
|
+
throw [GcException]::new('nothing staged — run gc-stage with the paths, or pass -All', $script:GcExitPre)
|
|
123
|
+
}
|
|
124
|
+
Stop-GcOnSecrets -Root $root
|
|
125
|
+
$stat = Get-GcGit -Root $root -Argv @('diff','--cached','--stat')
|
|
126
|
+
Write-GcInfo 'staged diff (review before the commit lands):'
|
|
127
|
+
Write-GcNote (($stat -join "`n"))
|
|
128
|
+
|
|
129
|
+
$argv = @('commit','-m',$subject)
|
|
130
|
+
if ($bullets.Count -gt 0) { $argv += @('-m', ($bullets -join "`n")) }
|
|
131
|
+
Invoke-GcGit -Root $root -Argv $argv
|
|
132
|
+
|
|
133
|
+
$log = (Get-GcGit -Root $root -Argv @('log','-1','--format=%h%x09%s') | Select-Object -First 1).Trim()
|
|
134
|
+
$files = @(Get-GcGit -Root $root -Argv @('show','--format=','--name-only','-r','HEAD') | Where-Object { $_ }).Count
|
|
135
|
+
Write-GcOk "committed: $log"
|
|
136
|
+
Write-GcResult -Props @{ sha = ($log -split "`t")[0]; subject = ($log -split "`t")[1]; files = $files; action = 'committed' }
|
|
137
|
+
} catch [GcException] {
|
|
138
|
+
Write-GcFail $_.Exception.Message
|
|
139
|
+
Write-GcResult -Code $_.Exception.Code -Props @{ message = $_.Exception.Message }
|
|
140
|
+
} catch {
|
|
141
|
+
Write-GcFail "unexpected: $($_.Exception.Message)"
|
|
142
|
+
Write-GcResult -Code $script:GcExitFail -Props @{ message = $_.Exception.Message }
|
|
143
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#Requires -Version 7.0
|
|
2
|
+
<#
|
|
3
|
+
.SYNOPSIS
|
|
4
|
+
Merge a branch through its PR — squash by default, only when the checks are
|
|
5
|
+
green (main stays green, §6). Then delete the branch, local and remote, and
|
|
6
|
+
prune. No human in the middle.
|
|
7
|
+
|
|
8
|
+
.DESCRIPTION
|
|
9
|
+
git-ceremony §6 as a script. Refuses to merge while any check is failing or
|
|
10
|
+
(beyond -CheckTimeoutSec) still pending; a PR whose status rollup shows NO
|
|
11
|
+
checks proceeds with a warning — required-check enforcement is gh's own
|
|
12
|
+
backstop (gh refuses to merge a blocked PR). If the PR is a draft it is
|
|
13
|
+
marked ready first. The merge is verified (state == MERGED) before ANY
|
|
14
|
+
cleanup; the local branch is deleted only when it provably matches the
|
|
15
|
+
merged PR head (no guesswork, no unguarded -D), and the remote branch only
|
|
16
|
+
when the remote ref still exists. Re-runs after a completed merge are clean
|
|
17
|
+
no-ops that finish leftover cleanup (self-healing, idempotent).
|
|
18
|
+
|
|
19
|
+
Repo rules win: repos that dictate merge commits or rebase get -Mode
|
|
20
|
+
merge|rebase; a repo's own documented convention always beats this script.
|
|
21
|
+
|
|
22
|
+
.PARAMETER Branch
|
|
23
|
+
Head branch to merge. Defaults to the current branch. Ref-shaped and
|
|
24
|
+
validated (a leading dash is rejected outright).
|
|
25
|
+
.PARAMETER PR
|
|
26
|
+
Explicit PR number; defaults to the open PR for the branch.
|
|
27
|
+
.PARAMETER Mode
|
|
28
|
+
Merge method: squash (default), merge, or rebase.
|
|
29
|
+
.PARAMETER CheckTimeoutSec
|
|
30
|
+
How long to wait for pending checks before refusing (default 300; 0 = do
|
|
31
|
+
not wait — refuse while pending).
|
|
32
|
+
.PARAMETER NoDeleteBranch
|
|
33
|
+
Keep the branch after merge (ceremony deletes it; repos that want it kept
|
|
34
|
+
pass this).
|
|
35
|
+
.PARAMETER RepoRoot
|
|
36
|
+
Repository path (defaults to the current directory); git pinned with git -C,
|
|
37
|
+
gh run from the repo root.
|
|
38
|
+
.PARAMETER Detailed
|
|
39
|
+
Restore the step narration, ok/info lines, and raw git/gh relay the terse
|
|
40
|
+
default hides. Never affects the RESULT line, warnings, failures, or the
|
|
41
|
+
security/remediation lines.
|
|
42
|
+
.PARAMETER Quiet
|
|
43
|
+
Accepted for compatibility and now a no-op: the default is already terse.
|
|
44
|
+
-Quiet forces the gate closed and so wins if passed with -Detailed.
|
|
45
|
+
|
|
46
|
+
.EXAMPLE
|
|
47
|
+
pwsh -File scripts\gc-merge.ps1
|
|
48
|
+
|
|
49
|
+
.EXAMPLE
|
|
50
|
+
pwsh -File scripts\gc-merge.ps1 -Mode merge -CheckTimeoutSec 600
|
|
51
|
+
#>
|
|
52
|
+
param(
|
|
53
|
+
[string]$Branch,
|
|
54
|
+
[int]$PR,
|
|
55
|
+
[ValidateSet('squash','merge','rebase')][string]$Mode = 'squash',
|
|
56
|
+
[int]$CheckTimeoutSec = 300,
|
|
57
|
+
[switch]$AllowNoChecks,
|
|
58
|
+
[switch]$NoDeleteBranch,
|
|
59
|
+
[string]$RepoRoot = (Get-Location).Path,
|
|
60
|
+
[switch]$Detailed,
|
|
61
|
+
[switch]$Quiet
|
|
62
|
+
)
|
|
63
|
+
Set-StrictMode -Version Latest
|
|
64
|
+
$ErrorActionPreference = 'Stop'
|
|
65
|
+
. (Join-Path $PSScriptRoot 'gc.core.ps1')
|
|
66
|
+
if ($Detailed) { $script:GcQuiet = $false }
|
|
67
|
+
if ($Quiet) { $script:GcQuiet = $true }
|
|
68
|
+
|
|
69
|
+
function Get-GcChecksRollup {
|
|
70
|
+
param([Parameter(Mandatory)][string]$Root, [Parameter(Mandatory)][int]$Number)
|
|
71
|
+
$raw = @(Get-GcGhJson -Root $Root -Argv @('pr','view',"$Number",'--json','statusCheckRollup','--jq','.statusCheckRollup'))
|
|
72
|
+
if (-not $raw -or ($raw.Count -eq 1 -and $null -eq $raw[0])) { return @() }
|
|
73
|
+
return $raw
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function Get-GcChecksVerdict {
|
|
77
|
+
<#
|
|
78
|
+
'pass' | 'pending' | 'fail' | 'unknown'. Handles BOTH rollup shapes under
|
|
79
|
+
StrictMode: CheckRun items (status/conclusion) and legacy StatusContext
|
|
80
|
+
items (state only) — property access is guarded via PSObject.Properties so
|
|
81
|
+
a missing property can never throw. 'unknown' = rollup empty (no checks
|
|
82
|
+
reported — gh required-check enforcement remains the backstop).
|
|
83
|
+
#>
|
|
84
|
+
param($Rollup)
|
|
85
|
+
if (-not $Rollup) { return 'unknown' }
|
|
86
|
+
foreach ($c in $Rollup) {
|
|
87
|
+
if ($null -eq $c) { continue } # a null rollup item must not crash the loop
|
|
88
|
+
if ($c.PSObject.Properties['status'] -and $c.status -in @('QUEUED','IN_PROGRESS')) { return 'pending' }
|
|
89
|
+
if ($c.PSObject.Properties['state'] -and $c.state -in @('FAILURE','ERROR')) { return 'fail' }
|
|
90
|
+
if ($c.PSObject.Properties['state'] -and $c.state -in @('PENDING','EXPECTED')) { return 'pending' }
|
|
91
|
+
if ($c.PSObject.Properties['conclusion'] -and $c.conclusion -and $c.conclusion -notin @('SUCCESS','NEUTRAL','SKIPPED')) { return 'fail' }
|
|
92
|
+
}
|
|
93
|
+
return 'pass'
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
try {
|
|
97
|
+
$root = Resolve-GcRoot -Path $RepoRoot
|
|
98
|
+
Write-GcInfo "repo: $root"
|
|
99
|
+
|
|
100
|
+
$head = if ($Branch) { $Branch } else { Get-GcCurrentBranch -Root $root }
|
|
101
|
+
if ($Branch) { Assert-GcRefValue -Name '-Branch' -Value $head }
|
|
102
|
+
$default = Get-GcDefaultBranch -Root $root
|
|
103
|
+
if ($head -eq $default) {
|
|
104
|
+
throw [GcException]::new("you are on the default branch ($default) — nothing to merge; pass -Branch <head> to finish an already-merged PR or gc-branch a new unit of work", $script:GcExitPre)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Assert-GcGh
|
|
108
|
+
|
|
109
|
+
# resolve the PR ONCE — statusCheckRollup rides along, so the checks verdict
|
|
110
|
+
# costs no second gh call (was: 2x pr view, plus a re-poll per wait tick)
|
|
111
|
+
$prFields = 'number,state,headRefName,headRefOid,baseRefName,isDraft,mergeCommit,statusCheckRollup'
|
|
112
|
+
$prInfo = $null
|
|
113
|
+
if ($PR) {
|
|
114
|
+
try { $prInfo = Get-GcGhJson -Root $root -Argv @('pr','view',"$PR",'--json',$prFields) }
|
|
115
|
+
catch { throw [GcException]::new("no PR #$PR — $($_.Exception.Message)", $script:GcExitPre) }
|
|
116
|
+
if ($prInfo.headRefName -ne $head) {
|
|
117
|
+
throw [GcException]::new("PR #$PR is for branch $($prInfo.headRefName), not $head", $script:GcExitPre)
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
try {
|
|
121
|
+
$prInfo = Get-GcGhJson -Root $root -Argv @('pr','view',$head,'--json',$prFields)
|
|
122
|
+
} catch {
|
|
123
|
+
if ($_.Exception.Message -match 'no pull requests found') {
|
|
124
|
+
throw [GcException]::new("no open PR for $head — create one with gc-pr", $script:GcExitPre)
|
|
125
|
+
}
|
|
126
|
+
throw
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
$n = $prInfo.number
|
|
131
|
+
$base = $prInfo.baseRefName
|
|
132
|
+
Assert-GcRefValue -Name 'base branch' -Value $base # hostile gh data is validated too
|
|
133
|
+
if ($base -ne $default) {
|
|
134
|
+
throw [GcException]::new("PR #$n targets base '$base', not the default branch '$default' — mis-targeted PR; retarget it (gh pr edit --base) or merge by hand", $script:GcExitPre)
|
|
135
|
+
}
|
|
136
|
+
Write-GcInfo "PR #$n : $head -> $base (state $($prInfo.state))"
|
|
137
|
+
|
|
138
|
+
if ($prInfo.state -eq 'MERGED') {
|
|
139
|
+
Write-GcOk "PR #$n already merged — finishing leftover cleanup"
|
|
140
|
+
# truthful method label comes from the merge commit itself (gh exposes
|
|
141
|
+
# no message) — resolved after the cleanup fetches it (freshMerged=false).
|
|
142
|
+
$mergedSha = if ($prInfo.mergeCommit) { $prInfo.mergeCommit.oid } else { '' }
|
|
143
|
+
$freshMerged = $false
|
|
144
|
+
# fall through to cleanup only
|
|
145
|
+
} elseif ($prInfo.state -eq 'CLOSED') {
|
|
146
|
+
throw [GcException]::new("PR #$n is closed — re-open or create a new PR before merging", $script:GcExitPre)
|
|
147
|
+
} else {
|
|
148
|
+
# main stays green (§6): refuse failing, wait bounded for pending
|
|
149
|
+
$verdict = Get-GcChecksVerdict -Rollup @($prInfo.statusCheckRollup | Where-Object { $null -ne $_ })
|
|
150
|
+
if ($verdict -eq 'fail') {
|
|
151
|
+
throw [GcException]::new('checks are FAILING — main stays green; fix, push, and re-run', $script:GcExitPre)
|
|
152
|
+
}
|
|
153
|
+
if ($verdict -eq 'unknown' -and -not $AllowNoChecks) {
|
|
154
|
+
throw [GcException]::new('no checks visible in the status rollup — refusing; re-run with -AllowNoChecks only when the repository intentionally has no CI checks', $script:GcExitPre)
|
|
155
|
+
}
|
|
156
|
+
if ($verdict -eq 'unknown') {
|
|
157
|
+
Write-GcWarn 'no checks visible; proceeding only because -AllowNoChecks was explicit'
|
|
158
|
+
}
|
|
159
|
+
if ($verdict -eq 'pending') {
|
|
160
|
+
if ($CheckTimeoutSec -le 0) {
|
|
161
|
+
throw [GcException]::new('checks still pending and -CheckTimeoutSec 0 — re-run gc-merge when they finish', $script:GcExitPre)
|
|
162
|
+
}
|
|
163
|
+
# ungated: with chatter off a silent 15s-poll wait looked hung for up
|
|
164
|
+
# to 5 minutes. One phase line + one per tick, no change to interval.
|
|
165
|
+
Write-GcNotice "checks pending — waiting up to ${CheckTimeoutSec}s (poll every 15s)"
|
|
166
|
+
$sw = [System.Diagnostics.Stopwatch]::StartNew()
|
|
167
|
+
while ($verdict -eq 'pending' -and $sw.Elapsed.TotalSeconds -lt $CheckTimeoutSec) {
|
|
168
|
+
Start-Sleep -Seconds 15
|
|
169
|
+
$verdict = Get-GcChecksVerdict -Rollup (Get-GcChecksRollup -Root $root -Number $n)
|
|
170
|
+
if ($verdict -eq 'pending') { Write-GcNotice " still waiting: $([int]$sw.Elapsed.TotalSeconds)s elapsed of ${CheckTimeoutSec}s" }
|
|
171
|
+
}
|
|
172
|
+
if ($verdict -eq 'fail') {
|
|
173
|
+
throw [GcException]::new('checks turned FAILING while waiting — main stays green; fix, push, and re-run', $script:GcExitPre)
|
|
174
|
+
}
|
|
175
|
+
if ($verdict -eq 'pending') {
|
|
176
|
+
throw [GcException]::new("checks still pending after ${CheckTimeoutSec}s — re-run gc-merge when they finish", $script:GcExitPre)
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if ($prInfo.isDraft) {
|
|
180
|
+
Invoke-GcGh -Root $root -Argv @('pr','ready',"$n")
|
|
181
|
+
Write-GcInfo "PR #$n marked ready"
|
|
182
|
+
}
|
|
183
|
+
$method = Convert-GcMergeMode -Mode $Mode
|
|
184
|
+
Write-GcInfo "merging PR #$n with $Mode..."
|
|
185
|
+
Invoke-GcGh -Root $root -Argv @('pr','merge',"$n",$method)
|
|
186
|
+
$st = Get-GcGhJson -Root $root -Argv @('pr','view',"$n",'--json','state,mergeStateStatus,mergeCommit')
|
|
187
|
+
if ($st.state -ne 'MERGED') {
|
|
188
|
+
throw [GcException]::new("merge did not land — gh reports mergeStateStatus '$($st.mergeStateStatus)' — likely conflicts: rebase on $default, gc-push -Force (lease), re-run", $script:GcExitPre)
|
|
189
|
+
}
|
|
190
|
+
$mergedSha = $st.mergeCommit.oid
|
|
191
|
+
$freshMerged = $true
|
|
192
|
+
Write-GcOk "PR #$n merged ($Mode) @ $mergedSha"
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# ----- cleanup: branch deletion, local and remote, verified ------------
|
|
196
|
+
$deletedLocal = $false; $deletedRemote = $false; $syncSkipped = $false
|
|
197
|
+
$cleanupWarn = $null; $keptWarn = $null
|
|
198
|
+
if (-not $NoDeleteBranch) {
|
|
199
|
+
try {
|
|
200
|
+
Invoke-GcGit -Root $root -Argv @('switch',$base) # cannot delete the branch we are on
|
|
201
|
+
if ((Test-GcRef -Root $root -Ref "refs/heads/$head") -and $head -ne (Get-GcCurrentBranch -Root $root)) {
|
|
202
|
+
$localNow = (Get-GcGit -Root $root -Argv @('rev-parse',$head) | Select-Object -First 1).Trim()
|
|
203
|
+
if ($localNow -eq $prInfo.headRefOid) {
|
|
204
|
+
Invoke-GcGit -Root $root -Argv @('branch','-D',$head)
|
|
205
|
+
$deletedLocal = $true
|
|
206
|
+
} else {
|
|
207
|
+
$keptWarn = "local $head moved after merge ($localNow != merged $($prInfo.headRefOid)) — left intact (name re-used?)"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
$remote = $null
|
|
211
|
+
try { $remote = Get-GcRemote -Root $root } catch { }
|
|
212
|
+
if ($remote) {
|
|
213
|
+
$remoteHeads = @(Get-GcGit -Root $root -Argv @('ls-remote','--heads',$remote,$head))
|
|
214
|
+
if ($remoteHeads) {
|
|
215
|
+
# remote delete is oid-gated like the local one: a post-merge
|
|
216
|
+
# push or a re-used name must never be wiped.
|
|
217
|
+
$remoteSha = ($remoteHeads[0] -split "`t")[0].Trim()
|
|
218
|
+
if ($remoteSha -eq $prInfo.headRefOid) {
|
|
219
|
+
Invoke-GcGit -Root $root -Argv @('push',$remote,'--delete',$head)
|
|
220
|
+
$deletedRemote = $true
|
|
221
|
+
} else {
|
|
222
|
+
$keptWarn = "remote $head moved after merge ($remoteSha != merged $($prInfo.headRefOid)) — remote left intact"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
$remotes = @(Get-GcGit -Root $root -Argv @('remote'))
|
|
227
|
+
if ($remotes -contains 'origin') {
|
|
228
|
+
Invoke-GcGit -Root $root -Argv @('fetch','--prune','origin')
|
|
229
|
+
}
|
|
230
|
+
} catch {
|
|
231
|
+
$cleanupWarn = "cleanup incomplete: $($_.Exception.Message)"
|
|
232
|
+
}
|
|
233
|
+
# post-merge sync is best-effort: a dirty tree or stray untracked files
|
|
234
|
+
# must never fail an already-landed merge — warn instead, self-heal later.
|
|
235
|
+
try {
|
|
236
|
+
$null = Sync-GcDefaultBranch -Root $root -Default $base -CurrentBranch (Get-GcCurrentBranch -Root $root)
|
|
237
|
+
} catch {
|
|
238
|
+
$syncSkipped = $true
|
|
239
|
+
Write-GcWarn "post-merge sync skipped: $($_.Exception.Message)"
|
|
240
|
+
}
|
|
241
|
+
if ($cleanupWarn) { Write-GcWarn $cleanupWarn }
|
|
242
|
+
if ($keptWarn) { Write-GcWarn $keptWarn }
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
# truthful merge-method label: our own run knows it; an already-merged PR's
|
|
246
|
+
# method is read from the merge commit itself (now fetched by the cleanup)
|
|
247
|
+
$modeOut = if ($freshMerged) { $Mode } else { Get-GcMergedMethod -Root $root -Sha $mergedSha }
|
|
248
|
+
|
|
249
|
+
$props = @{
|
|
250
|
+
number = $n
|
|
251
|
+
mode = $modeOut
|
|
252
|
+
sha = $mergedSha
|
|
253
|
+
branch = $head
|
|
254
|
+
branch_deleted_local = $deletedLocal
|
|
255
|
+
branch_deleted_remote = $deletedRemote
|
|
256
|
+
sync_skipped = $syncSkipped
|
|
257
|
+
}
|
|
258
|
+
if ($keptWarn) { $props.branch_kept = $keptWarn }
|
|
259
|
+
if ($cleanupWarn) {
|
|
260
|
+
$props.cleanup = $cleanupWarn
|
|
261
|
+
Write-GcFail "merged but cleanup incomplete: $cleanupWarn — re-run gc-merge to finish it"
|
|
262
|
+
Write-GcResult -Code $script:GcExitFail -Props $props
|
|
263
|
+
}
|
|
264
|
+
Write-GcOk "PR #$n merged ($modeOut) — branch cleanup done"
|
|
265
|
+
Write-GcResult -Props $props
|
|
266
|
+
} catch [GcException] {
|
|
267
|
+
Write-GcFail $_.Exception.Message
|
|
268
|
+
Write-GcResult -Code $_.Exception.Code -Props @{ message = $_.Exception.Message }
|
|
269
|
+
} catch {
|
|
270
|
+
Write-GcFail "unexpected: $($_.Exception.Message)"
|
|
271
|
+
Write-GcResult -Code $script:GcExitFail -Props @{ message = $_.Exception.Message }
|
|
272
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
#Requires -Version 7.0
|
|
2
|
+
<#
|
|
3
|
+
.SYNOPSIS
|
|
4
|
+
Open (or update) the pull request with the ceremony body. No editor, no
|
|
5
|
+
prompts, no human in the middle.
|
|
6
|
+
|
|
7
|
+
.DESCRIPTION
|
|
8
|
+
git-ceremony §4 as a script. Title defaults to the branch head commit subject
|
|
9
|
+
("Title = the commit subject"). Body is exactly the fixed shape:
|
|
10
|
+
|
|
11
|
+
What: <one line>
|
|
12
|
+
Why: <one line, omitted when obvious>
|
|
13
|
+
Check: <the single command that proves it, or n/a>
|
|
14
|
+
Risk: <one line, or low>
|
|
15
|
+
|
|
16
|
+
Self-healing: an existing open PR for the branch is updated in place; a
|
|
17
|
+
closed PR is reopened and updated; an already-merged PR is a clean no-op.
|
|
18
|
+
Requires gh (exit 3 when missing or unauthenticated).
|
|
19
|
+
|
|
20
|
+
Repo rules win (§0): a repo with its own established PR structure — a
|
|
21
|
+
.github/PULL_REQUEST_TEMPLATE.md, or a consistent sibling-PR style — supplies
|
|
22
|
+
its body verbatim with -BodyFile (or -Body). The fixed shape above is the
|
|
23
|
+
FALLBACK ceremony for a repo that is silent.
|
|
24
|
+
|
|
25
|
+
.PARAMETER Title
|
|
26
|
+
PR title. Defaults to the branch head commit subject; validated with the
|
|
27
|
+
same rule as the commit subject.
|
|
28
|
+
.PARAMETER What
|
|
29
|
+
One line: what this PR does. Required unless -Body/-BodyFile supplies the
|
|
30
|
+
repo's own body.
|
|
31
|
+
.PARAMETER Why
|
|
32
|
+
One line: why it exists. Omit (leave empty) when obvious.
|
|
33
|
+
.PARAMETER Check
|
|
34
|
+
The single command that proves it. Defaults to n/a.
|
|
35
|
+
.PARAMETER Risk
|
|
36
|
+
One line risk. Defaults to low.
|
|
37
|
+
.PARAMETER Body
|
|
38
|
+
The repo's own PR body, verbatim, for a repo with an established structure.
|
|
39
|
+
Mutually exclusive with -BodyFile.
|
|
40
|
+
.PARAMETER BodyFile
|
|
41
|
+
Path to a file holding the repo's own PR body, used verbatim. A missing,
|
|
42
|
+
unreadable or empty file is a loud stop (exit 2) — never a silent empty body.
|
|
43
|
+
.PARAMETER Base
|
|
44
|
+
Base branch. Defaults to the repo default branch.
|
|
45
|
+
.PARAMETER Draft
|
|
46
|
+
Open as a draft (ready only when the check passes, §4).
|
|
47
|
+
.PARAMETER RepoRoot
|
|
48
|
+
Repository path (defaults to the current directory); gh is run from the repo
|
|
49
|
+
root.
|
|
50
|
+
.PARAMETER Detailed
|
|
51
|
+
Restore the step narration, ok/info lines, and raw git/gh relay the terse
|
|
52
|
+
default hides. Never affects the RESULT line, warnings, failures, or the
|
|
53
|
+
security/remediation lines.
|
|
54
|
+
.PARAMETER Quiet
|
|
55
|
+
Accepted for compatibility and now a no-op: the default is already terse.
|
|
56
|
+
-Quiet forces the gate closed and so wins if passed with -Detailed.
|
|
57
|
+
|
|
58
|
+
.EXAMPLE
|
|
59
|
+
pwsh -File scripts\gc-pr.ps1 -What 'Cap retry backoff at 30s' `
|
|
60
|
+
-Check 'dotnet test' -Risk 'low' -Draft
|
|
61
|
+
|
|
62
|
+
.EXAMPLE
|
|
63
|
+
# the repo has its own PR structure (§0): hand it over verbatim
|
|
64
|
+
pwsh -File scripts\gc-pr.ps1 -BodyFile .\.docs\pr-body.md
|
|
65
|
+
#>
|
|
66
|
+
param(
|
|
67
|
+
[string]$Title,
|
|
68
|
+
[string]$What,
|
|
69
|
+
[string]$Why,
|
|
70
|
+
[string]$Check,
|
|
71
|
+
[string]$Risk,
|
|
72
|
+
[string]$Body,
|
|
73
|
+
[string]$BodyFile,
|
|
74
|
+
[string]$Base,
|
|
75
|
+
[switch]$Draft,
|
|
76
|
+
[string]$RepoRoot = (Get-Location).Path,
|
|
77
|
+
[switch]$Detailed,
|
|
78
|
+
[switch]$Quiet
|
|
79
|
+
)
|
|
80
|
+
Set-StrictMode -Version Latest
|
|
81
|
+
$ErrorActionPreference = 'Stop'
|
|
82
|
+
. (Join-Path $PSScriptRoot 'gc.core.ps1')
|
|
83
|
+
if ($Detailed) { $script:GcQuiet = $false }
|
|
84
|
+
if ($Quiet) { $script:GcQuiet = $true }
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
$root = Resolve-GcRoot -Path $RepoRoot
|
|
88
|
+
Write-GcInfo "repo: $root"
|
|
89
|
+
|
|
90
|
+
$cur = Get-GcCurrentBranch -Root $root
|
|
91
|
+
$default = Get-GcDefaultBranch -Root $root
|
|
92
|
+
$base = if ($Base) { $Base } else { $default }
|
|
93
|
+
if ($Base) { Assert-GcRefValue -Name '-Base' -Value $base }
|
|
94
|
+
Write-GcInfo "head: $cur base: $base"
|
|
95
|
+
|
|
96
|
+
# precondition, before gh: the head must already exist on the remote
|
|
97
|
+
# (§4 flow: push first). A forgotten gc-push must say so, not fail deep in gh.
|
|
98
|
+
$remote = Get-GcRemote -Root $root
|
|
99
|
+
if (-not @(Get-GcGit -Root $root -Argv @('ls-remote','--heads',$remote,$cur))) {
|
|
100
|
+
throw [GcException]::new("$cur is not on $remote — run gc-push first", $script:GcExitPre)
|
|
101
|
+
}
|
|
102
|
+
Assert-GcGh
|
|
103
|
+
|
|
104
|
+
# title defaults to the commit subject, and is validated like one (§4)
|
|
105
|
+
if (-not $Title) { $Title = (Get-GcGit -Root $root -Argv @('log','-1','--format=%s') | Select-Object -First 1).Trim() }
|
|
106
|
+
Get-GcSubjectParts -Subject $Title | Out-Null # throws Pre with the fix on any violation
|
|
107
|
+
|
|
108
|
+
# body (§0 precedence): a repo with its own established PR structure
|
|
109
|
+
# supplies it verbatim via -Body/-BodyFile; the fixed What/Why/Check/Risk
|
|
110
|
+
# shape is the FALLBACK for a repo that is silent. An override that is
|
|
111
|
+
# missing, unreadable or empty is a loud stop — a silently empty PR body is
|
|
112
|
+
# worse than a failed run.
|
|
113
|
+
$hasBody = $PSBoundParameters.ContainsKey('Body')
|
|
114
|
+
$hasBodyFile = $PSBoundParameters.ContainsKey('BodyFile')
|
|
115
|
+
if ($hasBody -and $hasBodyFile) {
|
|
116
|
+
throw [GcException]::new('-Body and -BodyFile are mutually exclusive — pass one body', $script:GcExitPre)
|
|
117
|
+
}
|
|
118
|
+
if ($hasBodyFile) {
|
|
119
|
+
if (-not $BodyFile -or -not (Test-Path -LiteralPath $BodyFile -PathType Leaf)) {
|
|
120
|
+
throw [GcException]::new("-BodyFile not found (or not a file): '$BodyFile' — pass the path to an existing PR body file", $script:GcExitPre)
|
|
121
|
+
}
|
|
122
|
+
try { $body = Get-Content -LiteralPath $BodyFile -Raw }
|
|
123
|
+
catch { throw [GcException]::new("-BodyFile could not be read: '$BodyFile' — $($_.Exception.Message)", $script:GcExitPre) }
|
|
124
|
+
if (-not $body -or -not $body.Trim()) {
|
|
125
|
+
throw [GcException]::new("-BodyFile is empty: '$BodyFile' — the PR body must not be blank", $script:GcExitPre)
|
|
126
|
+
}
|
|
127
|
+
if ($What -or $Why -or $Check -or $Risk) {
|
|
128
|
+
Write-GcWarn '-What/-Why/-Check/-Risk are ignored when -BodyFile supplies the body'
|
|
129
|
+
}
|
|
130
|
+
} elseif ($hasBody) {
|
|
131
|
+
if (-not $Body -or -not $Body.Trim()) {
|
|
132
|
+
throw [GcException]::new('-Body is empty — drop it to get the fixed What/Why/Check/Risk body', $script:GcExitPre)
|
|
133
|
+
}
|
|
134
|
+
$body = $Body
|
|
135
|
+
} else {
|
|
136
|
+
# fallback: exactly the fixed shape, one line per field
|
|
137
|
+
foreach ($v in @($What, $Why, $Check, $Risk)) {
|
|
138
|
+
if ($v -and ($v -match '\r?\n')) { throw [GcException]::new('body fields must be one line each — What/Why/Check/Risk', $script:GcExitPre) }
|
|
139
|
+
}
|
|
140
|
+
if (-not $What) { throw [GcException]::new('-What is required (or supply -Body/-BodyFile)', $script:GcExitPre) }
|
|
141
|
+
$body = Format-GcPrBody -What $What -Why $Why -Check $Check -Risk $Risk
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
# self-heal: reuse an existing PR for this branch — but a merged PR is a
|
|
145
|
+
# no-op ONLY when its head still matches local (a recreated/re-pushed
|
|
146
|
+
# branch with new commits must get a FRESH PR, never a false no-op).
|
|
147
|
+
$exists = $null
|
|
148
|
+
try {
|
|
149
|
+
$exists = Get-GcGhJson -Root $root -Argv @('pr','view',$cur,'--json','number,state,headRefOid')
|
|
150
|
+
} catch {
|
|
151
|
+
if ($_.Exception.Message -notmatch 'no pull requests found') { throw }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if ($exists) {
|
|
155
|
+
if ($exists.state -eq 'MERGED') {
|
|
156
|
+
$localHead = (Get-GcGit -Root $root -Argv @('rev-parse',$cur) | Select-Object -First 1).Trim()
|
|
157
|
+
if ($localHead -eq $exists.headRefOid) {
|
|
158
|
+
Write-GcOk "PR #$($exists.number) for $cur is already merged (head unchanged)"
|
|
159
|
+
Write-GcResult -Props @{ number = $exists.number; action = 'no-op'; state = 'merged' }
|
|
160
|
+
}
|
|
161
|
+
Write-GcWarn "PR #$($exists.number) is merged but $cur has moved on ($($localHead.Substring(0,[Math]::Min(7,$localHead.Length))) != $($exists.headRefOid.Substring(0,7))) — creating a fresh PR"
|
|
162
|
+
$exists = $null # fresh PR for the new commits
|
|
163
|
+
} elseif ($exists.state -eq 'CLOSED') {
|
|
164
|
+
Invoke-GcGh -Root $root -Argv @('pr','reopen',"$($exists.number)")
|
|
165
|
+
Write-GcInfo "reopened PR #$($exists.number)"
|
|
166
|
+
}
|
|
167
|
+
if ($exists) {
|
|
168
|
+
$argv = @('pr','edit',"$($exists.number)",'--title',$Title,'--body',$body)
|
|
169
|
+
# draft is set at create only — gh pr edit has no --draft (cannot be toggled on update)
|
|
170
|
+
Invoke-GcGh -Root $root -Argv $argv
|
|
171
|
+
$action = if ($exists.state -eq 'CLOSED') { 'reopened' } else { 'updated' }
|
|
172
|
+
Write-GcOk "PR #$($exists.number) $action"
|
|
173
|
+
$r = Get-GcGhJson -Root $root -Argv @('pr','view',"$($exists.number)",'--json','number,url')
|
|
174
|
+
Write-GcResult -Props @{ number = $r.number; url = $r.url; action = $action }
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
$argv = @('pr','create','--base',$base,'--head',$cur,'--title',$Title,'--body',$body)
|
|
179
|
+
if ($Draft) { $argv += '--draft' }
|
|
180
|
+
Invoke-GcGh -Root $root -Argv $argv
|
|
181
|
+
$r = Get-GcGhJson -Root $root -Argv @('pr','view',$cur,'--json','number,url,isDraft')
|
|
182
|
+
Write-GcOk "PR #$($r.number) created ($(if ($r.isDraft) { 'draft' } else { 'ready' }))"
|
|
183
|
+
Write-GcResult -Props @{ number = $r.number; url = $r.url; action = 'created'; draft = $r.isDraft }
|
|
184
|
+
} catch [GcException] {
|
|
185
|
+
Write-GcFail $_.Exception.Message
|
|
186
|
+
Write-GcResult -Code $_.Exception.Code -Props @{ message = $_.Exception.Message }
|
|
187
|
+
} catch {
|
|
188
|
+
Write-GcFail "unexpected: $($_.Exception.Message)"
|
|
189
|
+
Write-GcResult -Code $script:GcExitFail -Props @{ message = $_.Exception.Message }
|
|
190
|
+
}
|