Skip to content

Commit f99dc2f

Browse files
committed
Prevent public builds on non-release branches without --force option
1 parent 691ad4a commit f99dc2f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/PostSharp.Engineering.BuildTools/Build/BuildCommand.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,22 @@ public static bool Execute( BuildContext context, BuildSettings settings )
6262
dateTag = DateTime.Now;
6363
}
6464

65+
// Refuse to perform a public build on a non-release branch.
66+
if ( configuration == BuildConfiguration.Public && !settings.Force )
67+
{
68+
if ( !GitHelper.TryGetCurrentBranch( context, out var currentBranch ) )
69+
{
70+
return false;
71+
}
72+
73+
if ( !currentBranch.StartsWith( "release/", StringComparison.OrdinalIgnoreCase ) )
74+
{
75+
context.Console.WriteError( "Cannot perform a public build on a non-release branch without --force." );
76+
77+
return false;
78+
}
79+
}
80+
6581
// Build dependencies.
6682
DependenciesConfigurationFile? dependenciesOverrideFile;
6783

0 commit comments

Comments
 (0)