-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
61 lines (50 loc) · 2 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AutoCloner.VsOnline.Dto;
namespace AutoCloner.VsOnline
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Starting Multi-project clone engine.");
Console.WriteLine();
var settings = SettingsProvider.Hardcoded();
var engine = RegisterServicesAndGetEngine();
var results = engine.Run(settings);
var changes = results.Where(x => x.Status != CloneStatus.FolderExists).ToArray();
LogNewResults(settings.CloneBaseDirectory, changes);
Console.WriteLine();
Console.WriteLine("Multi-project clone engine completed.");
Console.WriteLine();
Console.ReadKey();
Console.WriteLine();
}
private static void LogNewResults(string path, IEnumerable<CloneResult> results)
{
var now = DateTime.Now.ToString("yy-mm-dd-hh-MM-ss");
var filename = Path.Combine(path, $"RepoChanges-{now}.json");
var json = JsonConvert.SerializeObject(results);
File.WriteAllText(filename, json);
}
private static Engine RegisterServicesAndGetEngine()
{
var services = new ServiceCollection()
.AddSingleton<Engine>()
.AddSingleton<IGitRunner, CommandLineGitRunner>()
.AddSingleton<ICloner, GitCloner>()
.AddSingleton<IVsOnlineApiClient, VsOnlineApiClient>()
.AddSingleton<IRepositoryEnumerator, VsOnlineRepositoryEnumerator>()
.AddSingleton<IProjectEnumerator, VsOnlineApiProjectEnumerator>()
.AddLogging(c => c.AddConsole())
;
var provider = services.BuildServiceProvider();
return provider.GetService<Engine>();
}
}
}