private static void CommitIntoTempRepo(TempDirectory url, string branch) { using (new DirectoryJumper(url.Path)) { var runner = new ShellRunner(); runner.Run("git checkout " + branch); File.WriteAllText(Path.Combine(url.Path, "content.txt"), "README"); runner.Run("git add content.txt"); runner.Run(@"git commit -am added"); } }
private static void CreateTempRepo(TempDirectory url) { using (new DirectoryJumper(url.Path)) { File.WriteAllText(Path.Combine(url.Path, "README.txt"), "README"); var runner = new ShellRunner(); runner.Run("git init"); runner.Run("git add README.txt"); runner.Run(@"git commit -am initial"); } }
public void TestGitTreeishOnTag() { using (var tempRepo = new TempDirectory()) { CreateTempRepo(tempRepo); using (new DirectoryJumper(tempRepo.Path)) { var runner = new ShellRunner(); runner.Run("git tag testTag"); runner.Run("git checkout testTag"); } var repo = new GitRepository(Path.GetFileName(tempRepo.Path), Directory.GetParent(tempRepo.Path).FullName, Log); Assert.AreEqual("testTag", repo.CurrentLocalTreeish().Value); Assert.AreEqual(TreeishType.Tag, repo.CurrentLocalTreeish().Type); } }
public static void AppendLogger(string loggerPath, IEnumerable <string> componentPaths, ILog log) { var baseDirectory = Path.GetDirectoryName(loggerPath); var loggerName = Path.GetFileName(loggerPath); var extractor = new ShellRunner(new ShellRunnerSettings("jar") { Arguments = $"-xf {loggerName} org", WorkingDirectory = baseDirectory }, log); var updateTasks = componentPaths.Select(x => { var filename = Path.GetFileName(x); var updater = new ShellRunner(new ShellRunnerSettings("jar") { Arguments = $"-uf {filename} org", WorkingDirectory = baseDirectory }, log); return(updater.RunAsync(TimeSpan.FromSeconds(30), CancellationToken.None)); }).ToArray(); extractor.Run(TimeSpan.FromSeconds(30), CancellationToken.None); Task.WaitAll(updateTasks); }
private static int Main(string[] args) { var services = new ServiceCollection(); ConfigureServices(services); var serviceProvider = services.BuildServiceProvider(); ConfigureLogging(serviceProvider); var logger = serviceProvider.GetService <ILogger <Program> >(); var runner = new ShellRunner(serviceProvider); try { runner.LoadFile(args[0]); for (int i = 1; i < args.Length; i++) { if (args[i].StartsWith("--")) { string name = args[i].Substring(2); i++; if (i >= args.Length) { break; } runner.Context.SetVariable(name, args[i]); } else if (args[i] == "/sqlconn") { i++; if (i >= args.Length) { break; } string sqlconn = args[i]; runner.Context.SetDefaultConnection("sqlserver://" + sqlconn); } } } catch (Exception err) { logger.LogError(err, "DBSH-00146 Error loading input DbShell script"); return(1); } try { runner.Run(); } catch (Exception err) { logger.LogError(err, "DBSH-00147 Error running process"); return(2); } return(0); }
private static void CreateNewBranchInTempRepo(TempDirectory url, string branchName) { using (new DirectoryJumper(url.Path)) { var runner = new ShellRunner(); runner.Run("git branch " + branchName); } }
public void TestGitTreeishDetached() { using (var tempRepo = new TempDirectory()) { CreateTempRepo(tempRepo); string sha1; using (new DirectoryJumper(tempRepo.Path)) { var runner = new ShellRunner(); runner.Run("git rev-parse HEAD"); sha1 = runner.Output.Trim(); runner.Run("git checkout " + sha1); } var repo = new GitRepository(Path.GetFileName(tempRepo.Path), Directory.GetParent(tempRepo.Path).FullName, Log); Assert.AreEqual(sha1, repo.CurrentLocalTreeish().Value); Assert.AreEqual(TreeishType.CommitHash, repo.CurrentLocalTreeish().Type); } }
private void CreateBranches(IList <string> branches) { if (branches == null) { return; } foreach (var branch in branches) { runner.Run("git branch " + branch); } }
public void TestRunCommand() { Assert.AreEqual(0, runner.Run(Helper.OsIsUnix() ? "ls" : "dir")); }
public void Checkout(string moduleName, string branch) { using (new DirectoryJumper(Path.Combine(RemoteWorkspace, moduleName))) { runner.Run("git checkout " + branch); } }
public void Run(TimeSpan timeout) { Configure(); shellRunner.Run(timeout, CancellationToken.None); }