Skip to content

Commit 15ff18b

Browse files
committed
update-eng auto-repeats until success.
1 parent 69292cb commit 15ff18b

File tree

2 files changed

+46
-5
lines changed

2 files changed

+46
-5
lines changed

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

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,42 @@
99
using System.Linq;
1010
using System.Net.Http;
1111
using System.Text.Json;
12+
using System.Threading;
1213
using System.Xml.Linq;
1314
using System.Xml.XPath;
1415

1516
namespace PostSharp.Engineering.BuildTools.Dependencies;
1617

1718
[UsedImplicitly]
18-
internal class UpdateEngineeringCommand : BaseCommand<CommonCommandSettings>
19+
internal class UpdateEngineeringCommand : BaseCommand<UpdateEngineeringCommandSettings>
1920
{
20-
protected override bool ExecuteCore( BuildContext context, CommonCommandSettings settings )
21+
protected override bool ExecuteCore( BuildContext context, UpdateEngineeringCommandSettings settings )
22+
{
23+
if ( settings.Repeat )
24+
{
25+
do
26+
{
27+
var exitCode = this.ExecuteOnce( context );
28+
29+
if ( exitCode == ExitCode.Success )
30+
{
31+
return true;
32+
}
33+
34+
context.Console.WriteMessage( "Waiting for 30 seconds." );
35+
Thread.Sleep( TimeSpan.FromSeconds( 30 ) );
36+
}
37+
while ( true );
38+
}
39+
else
40+
{
41+
context.ExitCode = this.ExecuteOnce( context );
42+
43+
return context.ExitCode == ExitCode.Success;
44+
}
45+
}
46+
47+
private ExitCode ExecuteOnce( BuildContext context )
2148
{
2249
var httpClient = new HttpClient();
2350

@@ -132,13 +159,14 @@ protected override bool ExecuteCore( BuildContext context, CommonCommandSettings
132159

133160
// Generate scripts.
134161
console.WriteWarning( "Now run `./Build.ps1 generate-scripts` with this new version." );
162+
163+
return ExitCode.Success;
135164
}
136165
else
137166
{
138167
console.WriteWarning( $"PostSharp.Engineering was already of the latest version ({lastVersion})." );
139-
context.ExitCode = ExitCode.NoChangeMade;
140-
}
141168

142-
return true;
169+
return ExitCode.NoChangeMade;
170+
}
143171
}
144172
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using JetBrains.Annotations;
2+
using Spectre.Console.Cli;
3+
using System.ComponentModel;
4+
5+
namespace PostSharp.Engineering.BuildTools.Dependencies;
6+
7+
[UsedImplicitly]
8+
internal class UpdateEngineeringCommandSettings : CommonCommandSettings
9+
{
10+
[Description( "Repeat until a new version is discovered." )]
11+
[CommandOption( "--repeat" )]
12+
public bool Repeat { get; init; }
13+
}

0 commit comments

Comments
 (0)