11// Copyright (c) SharpCrafters s.r.o. See the LICENSE.md file in the root directory of this repository root for details.
22
3+ using JetBrains . Annotations ;
34using PostSharp . Engineering . BuildTools . Build . Model ;
5+ using PostSharp . Engineering . BuildTools . ContinuousIntegration ;
46using PostSharp . Engineering . BuildTools . Utilities ;
57using Spectre . Console . Cli ;
68using System ;
@@ -71,21 +73,24 @@ private BuildContext(
7173 BaseCommandData commandData ,
7274 string branch ,
7375 CommandContext commandContext ,
74- bool useProjectDirectoryAsWorkingDirectory )
76+ bool useProjectDirectoryAsWorkingDirectory ,
77+ CommonCommandSettings settings )
7578 {
7679 this . Console = console ;
7780 this . RepoDirectory = repoDirectory ;
7881 this . CommandData = commandData ;
7982 this . Branch = branch ;
8083 this . CommandContext = commandContext ;
8184 this . UseProjectDirectoryAsWorkingDirectory = useProjectDirectoryAsWorkingDirectory ;
85+ this . Settings = settings ;
8286 }
8387
8488 /// <summary>
8589 /// Tries to create a <see cref="BuildContext"/> from a <see cref="Spectre.Console.Cli.CommandContext"/>.
8690 /// </summary>
8791 public static bool TryCreate (
8892 CommandContext commandContext ,
93+ CommonCommandSettings settings ,
8994 [ NotNullWhen ( true ) ] out BuildContext ? buildContext )
9095 {
9196 buildContext = null ;
@@ -110,7 +115,8 @@ public static bool TryCreate(
110115 ( BaseCommandData ) commandContext . Data ! ,
111116 currentBranch ,
112117 commandContext ,
113- useProjectDirectoryAsWorkingDirectory : false ) ;
118+ useProjectDirectoryAsWorkingDirectory : false ,
119+ settings ) ;
114120
115121 return true ;
116122 }
@@ -147,9 +153,19 @@ public static bool TryCreate(
147153 }
148154
149155 public BuildContext WithConsoleHelper ( ConsoleHelper consoleHelper )
150- => new ( consoleHelper , this . RepoDirectory , this . CommandData , this . Branch , this . CommandContext , this . UseProjectDirectoryAsWorkingDirectory ) ;
156+ => new ( consoleHelper , this . RepoDirectory , this . CommandData , this . Branch , this . CommandContext , this . UseProjectDirectoryAsWorkingDirectory , this . Settings ) ;
151157
152158 public BuildContext WithUseProjectDirectoryAsWorkingDirectory ( bool useProjectDirectoryAsWorkingDirectory )
153- => new ( this . Console , this . RepoDirectory , this . CommandData , this . Branch , this . CommandContext , useProjectDirectoryAsWorkingDirectory ) ;
159+ => new ( this . Console , this . RepoDirectory , this . CommandData , this . Branch , this . CommandContext , useProjectDirectoryAsWorkingDirectory , this . Settings ) ;
160+
161+ [ PublicAPI ]
162+ #pragma warning disable CA1822
163+ public bool IsRunningUnderContainer => DockerHelper . IsDockerBuild ( ) ;
164+ #pragma warning restore CA1822
165+
166+ public bool IsContinuousIntegrationBuild => TeamCityHelper . IsTeamCityBuild ( this . Settings ) ;
167+
168+ [ PublicAPI ]
169+ public CommonCommandSettings Settings { get ; }
154170 }
155171}
0 commit comments