Skip to content

Commit 8d67046

Browse files
committed
Special return code when update-eng made no change.
1 parent 24552e9 commit 8d67046

File tree

5 files changed

+39
-17
lines changed

5 files changed

+39
-17
lines changed

src/PostSharp.Engineering.BuildTools/BaseCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,21 @@ public sealed override int Execute( CommandContext context, T settings )
156156

157157
if ( buildContext.CancellationToken.IsCancellationRequested )
158158
{
159-
return (int) ExitCodes.Cancelled;
159+
return (int) ExitCode.Cancelled;
160160
}
161161

162162
if ( !settings.NoLogo )
163163
{
164164
buildContext.Console.WriteMessage( $"Finished at {DateTime.Now} after {stopwatch.Elapsed}." );
165165
}
166166

167-
return (int) (success ? ExitCodes.Success : ExitCodes.Error);
167+
return (int) (success ? buildContext.ExitCode : ExitCode.Error);
168168
}
169169
catch ( Exception ex )
170170
{
171171
AnsiConsole.WriteException( ex );
172172

173-
return (int) ExitCodes.Exception;
173+
return (int) ExitCode.Exception;
174174
}
175175
finally
176176
{

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ internal TimeSpan BuildTimeout
200200
}
201201
}
202202

203-
// Adds a margin to dump the hanging processes.
204-
internal TimeSpan BuildTimeoutWithMargin => this.BuildTimeout.Add( TimeSpan.FromMinutes( 5 ) );
203+
/// <summary>
204+
/// Gets or sets the exit code in case the <see cref="BaseCommand{T}.ExecuteCore"/> method returns <c>true</c>.
205+
/// </summary>
206+
public ExitCode ExitCode { get; set; } = ExitCode.Success;
205207
}
206208
}

src/PostSharp.Engineering.BuildTools/Dependencies/UpdateEngineeringCommand.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ protected override bool ExecuteCore( BuildContext context, CommonCommandSettings
136136
else
137137
{
138138
console.WriteWarning( $"PostSharp.Engineering was already of the latest version ({lastVersion})." );
139+
context.ExitCode = ExitCode.NoChangeMade;
139140
}
140141

141142
return true;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
2+
3+
namespace PostSharp.Engineering.BuildTools;
4+
5+
public enum ExitCode
6+
{
7+
/// <summary>
8+
/// Success.
9+
/// </summary>
10+
Success,
11+
12+
/// <summary>
13+
/// Handled error.
14+
/// </summary>
15+
Error,
16+
17+
/// <summary>
18+
/// No change was made.
19+
/// </summary>
20+
NoChangeMade,
21+
22+
/// <summary>
23+
/// Unhandled exception.
24+
/// </summary>
25+
Exception = 100,
26+
27+
/// <summary>
28+
/// Cancelled through Ctrl+C.
29+
/// </summary>
30+
Cancelled = 200
31+
}

src/PostSharp.Engineering.BuildTools/ExitCodes.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)