Skip to content

Commit 2727ce3

Browse files
committed
Improve GitRepoPublisher and RunClaude script
- Use ParametricString in GitRepoPublisher for URL and commit message to support $(PackageVersion) - Rename RunClaude.g.ps1 to RunClaude.ps1 and add Docker environment check - Add important notice to CLAUDE.md about reading skills before work
1 parent 552af4b commit 2727ce3

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
Build orchestration SDK for PostSharp/Metalama repositories.
44

5+
> [!IMPORTANT]
6+
> Read this file entirely before doing any work or answering any question for this project, especially regarding loading skills.
7+
58
## Discovering Plugin Skills
69

710
The `postsharp-engineering` plugin provides skills and slash commands. To discover them:

src/PostSharp.Engineering.BuildTools/Build/Publishing/GitRepoPublisher.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ namespace PostSharp.Engineering.BuildTools.Build.Publishing;
1717
[PublicAPI]
1818
public class GitRepoPublisher : ArtifactPublisher
1919
{
20-
private readonly string _gitHubUrl;
21-
private readonly string _commitMessage;
20+
private readonly ParametricString _gitHubUrl;
21+
private readonly ParametricString _commitMessage;
2222

2323
/// <summary>
2424
/// Initializes a new instance of the <see cref="GitRepoPublisher"/> class.
2525
/// </summary>
2626
/// <param name="files">The pattern matching the zip file(s) to publish.</param>
27-
/// <param name="gitHubUrl">The GitHub repository URL to publish to.</param>
28-
/// <param name="commitMessage">The commit message to use when pushing changes.</param>
29-
public GitRepoPublisher( Pattern files, string gitHubUrl, string commitMessage ) : base( files )
27+
/// <param name="gitHubUrl">The GitHub repository URL to publish to. Supports parameters like <c>$(PackageVersion)</c>.</param>
28+
/// <param name="commitMessage">The commit message to use when pushing changes. Supports parameters like <c>$(PackageVersion)</c>.</param>
29+
public GitRepoPublisher( Pattern files, ParametricString gitHubUrl, ParametricString commitMessage ) : base( files )
3030
{
3131
this._gitHubUrl = gitHubUrl;
3232
this._commitMessage = commitMessage;
@@ -43,13 +43,13 @@ public override SuccessCode PublishFile(
4343

4444
console.WriteMessage( $"Publishing '{file}' to git repository '{this._gitHubUrl}'." );
4545

46-
// Expand environment variables in the URL and commit message.
47-
var gitHubUrl = Environment.ExpandEnvironmentVariables( this._gitHubUrl );
48-
var commitMessage = Environment.ExpandEnvironmentVariables( this._commitMessage );
46+
// Expand parametric strings like $(PackageVersion).
47+
var gitHubUrl = this._gitHubUrl.ToString( buildArguments );
48+
var commitMessage = this._commitMessage.ToString( buildArguments );
4949

5050
if ( string.IsNullOrEmpty( gitHubUrl ) )
5151
{
52-
console.WriteError( "The GitHub URL is empty or the environment variable is not defined." );
52+
console.WriteError( "The GitHub URL is empty." );
5353

5454
return SuccessCode.Fatal;
5555
}

src/PostSharp.Engineering.BuildTools/Resources/DockerBuild.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,13 +559,13 @@ if (-not $BuildImage)
559559
{
560560
# Non-interactive mode with prompt - no -it flags
561561
$dockerArgs = @()
562-
$inlineScript = "${substCommandsInline}& c:\Init.g.ps1; ${copyClaudeJsonScript}cd '$SourceDirName'; & .\eng\RunClaude.g.ps1 -Prompt `"$ClaudePrompt`""
562+
$inlineScript = "${substCommandsInline}& c:\Init.g.ps1; ${copyClaudeJsonScript}cd '$SourceDirName'; & .\eng\RunClaude.ps1 -Prompt `"$ClaudePrompt`""
563563
}
564564
else
565565
{
566566
# Interactive mode - requires TTY
567567
$dockerArgs = @("-it")
568-
$inlineScript = "${substCommandsInline}& c:\Init.g.ps1; ${copyClaudeJsonScript}cd '$SourceDirName'; & .\eng\RunClaude.g.ps1"
568+
$inlineScript = "${substCommandsInline}& c:\Init.g.ps1; ${copyClaudeJsonScript}cd '$SourceDirName'; & .\eng\RunClaude.ps1"
569569
}
570570

571571
$dockerArgsAsString = $dockerArgs -join " "

src/PostSharp.Engineering.BuildTools/Resources/RunClaude.g.ps1 renamed to src/PostSharp.Engineering.BuildTools/Resources/RunClaude.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ param(
77

88
$ErrorActionPreference = "Stop"
99

10+
if ($env:RUNNING_IN_DOCKER -ne "true")
11+
{
12+
Write-Error "This script must be run inside a Docker container. Set RUNNING_IN_DOCKER=true to override."
13+
exit 1
14+
}
15+
1016
Write-Host "Starting Claude CLI..." -ForegroundColor Green
1117

1218
# Run Claude

0 commit comments

Comments
 (0)