-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodman, Burton
authored and
Rodman, Burton
committed
Dec 17, 2018
1 parent
829a622
commit d199e93
Showing
12 changed files
with
336 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.vs/ | ||
.vscode/ | ||
|
||
bin/ | ||
obj/ | ||
|
||
nupkg/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
version: '1.0' | ||
|
||
# [required] Your TFS or Azure DevOps instance URL | ||
account: https://dev.azure.com/youraccount | ||
account: ${AzureDevOpsCollectionUrl} | ||
|
||
# [optional] Your Team Project name. Defaults to current directory name. | ||
project: MyProject | ||
# project: ${TeamProjectName} | ||
|
||
# [optional] Repository Name. Defaults to current directory name. | ||
repository: MyProject | ||
# repository: ${RepositoryName} | ||
|
||
# For branches, all values are optional and if not supplied are turned off. | ||
# boolean like values interpreted per https://yaml.org/type/bool.html | ||
# integer values interpreted per https://yaml.org/type/int.html | ||
|
||
branches: | ||
develop: | ||
master: | ||
minimum-reviewers: 2 # !!int = 0 | ||
approve-own-changes: true # !!bool = false | ||
complete-if-not-approved: true # !!bool = false | ||
reset-votes-on-new-change: true # !!bool = false | ||
automatic-reviewers: | ||
- burtonrodman # string, and identity that can be resolved in the account | ||
linked-work-items: ignore|warn|required # string = ignore | ||
comment-resolution: ignore|warn|required # string = ignore | ||
merge-strategy: none|squash|no-fast-forward # string = none | ||
build: TDB | ||
external-services: TBD | ||
- name: master | ||
# minimum-reviewers: 2 # !!int = 0 | ||
# approve-own-changes: true # !!bool = false | ||
# complete-if-not-approved: true # !!bool = false | ||
# reset-votes-on-new-change: true # !!bool = false | ||
# automatic-reviewers: | ||
# - burtonrodman # string, and identity that can be resolved in the account | ||
# linked-work-items: ignore|warn|required # string = ignore | ||
# comment-resolution: ignore|warn|required # string = ignore | ||
# merge-strategy: none|squash|no-fast-forward # string = none | ||
# build: TDB | ||
# external-services: TBD | ||
|
||
- name: develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using static azdo_init.ProcessUtilities; | ||
namespace azdo_init | ||
{ | ||
|
||
public class GitRepo | ||
{ | ||
private readonly ILogger logger; | ||
|
||
public GitRepo(ILogger logger) | ||
{ | ||
this.logger = logger; | ||
} | ||
|
||
public void EnsureExists() | ||
{ | ||
if (!Exists()) | ||
{ | ||
Init(); | ||
logger.WriteAction("repo initialized."); | ||
} | ||
else | ||
{ | ||
logger.WriteInformation("repo exists."); | ||
} | ||
} | ||
|
||
public bool Exists() | ||
{ | ||
return ExecuteProcess("git", "rev-parse", "--is-inside-work-tree").StartsWith("true"); | ||
} | ||
|
||
public static void Init() | ||
{ | ||
ExecuteProcess("git", "init"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace azdo_init | ||
{ | ||
public class HelpCommand | ||
{ | ||
public static bool IsHelpCommand(string arg) | ||
{ | ||
switch (arg) | ||
{ | ||
case "--help": | ||
case "-help": | ||
case "-h": | ||
case "/help": | ||
case "/h": | ||
case "?": | ||
case "/?": | ||
return true; | ||
default: | ||
return false; | ||
} | ||
|
||
} | ||
|
||
public static void ShowHelp() { | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
|
||
namespace azdo_init | ||
{ | ||
|
||
public interface ILogger | ||
{ | ||
void Write(string message, LoggerSeverity severity); | ||
} | ||
|
||
public enum LoggerSeverity | ||
{ | ||
Information, | ||
Action, | ||
Warning, | ||
Error | ||
} | ||
|
||
public static class LoggerExtensions | ||
{ | ||
|
||
public static void WriteInformation(this ILogger logger, string message) | ||
{ | ||
logger.Write(message, LoggerSeverity.Information); | ||
} | ||
|
||
public static void WriteAction(this ILogger logger, string message) | ||
{ | ||
logger.Write(message, LoggerSeverity.Action); | ||
} | ||
|
||
} | ||
|
||
public class ConsoleLogger : ILogger | ||
{ | ||
|
||
public void Write(string message, LoggerSeverity severity) | ||
{ | ||
Console.WriteLine($"{severity}, {message}"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.IO; | ||
|
||
namespace azdo_init | ||
{ | ||
|
||
public class InitFile | ||
{ | ||
private readonly ILogger logger; | ||
|
||
public InitFile(ILogger logger) | ||
{ | ||
this.logger = logger; | ||
} | ||
|
||
public static RepositoryOptions Deserialize(string path) | ||
{ | ||
return null; | ||
} | ||
|
||
public bool Exists() | ||
{ | ||
return File.Exists("azdo-init.yml"); | ||
} | ||
|
||
public void Create() { | ||
var fullPath = Path.GetFullPath("azdo-init.yml"); | ||
using (var stream = typeof(InitFile).Assembly.GetManifestResourceStream("azdo_init.template.yml")) | ||
using (var reader = new StreamReader(stream)) | ||
{ | ||
File.WriteAllText(fullPath, reader.ReadToEnd()); | ||
} | ||
logger.WriteAction($"created {fullPath}"); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Diagnostics; | ||
|
||
namespace azdo_init | ||
{ | ||
|
||
public static class ProcessUtilities | ||
{ | ||
|
||
public static string ExecuteProcess(string cmd, params string[] args) | ||
{ | ||
var info = new ProcessStartInfo(); | ||
info.FileName = cmd; | ||
info.Arguments = string.Join(' ', args); | ||
info.UseShellExecute = false; | ||
info.RedirectStandardOutput = true; | ||
|
||
var process = Process.Start(info); | ||
var output = process.StandardOutput.ReadToEnd(); | ||
process.WaitForExit(); | ||
return output; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using static azdo_init.HelpCommand; | ||
|
||
namespace azdo_init | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
// if (IsHelpCommand(args.FirstOrDefault())) { | ||
// ShowHelp(); | ||
// } | ||
|
||
var logger = new ConsoleLogger(); | ||
|
||
var gitrepo = new GitRepo(logger); | ||
gitrepo.EnsureExists(); | ||
|
||
var initfile = new InitFile(logger); | ||
if (!initfile.Exists()) | ||
{ | ||
initfile.Create(); | ||
return; | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System.Collections.Generic; | ||
using YamlDotNet.Serialization; | ||
|
||
namespace azdo_init | ||
{ | ||
public class RepositoryOptions | ||
{ | ||
[YamlMember(Alias = "account", ApplyNamingConventions = false)] | ||
public string AzureDevOpsCollectionUrl { get; set; } | ||
|
||
|
||
[YamlMember(Alias = "project", ApplyNamingConventions = false)] | ||
public string TeamProjectName { get; set; } | ||
|
||
|
||
[YamlMember(Alias = "repository", ApplyNamingConventions = false)] | ||
public string RepositoryName { get; set; } | ||
|
||
public string Version { get; set; } | ||
|
||
|
||
public List<BranchOptions> Branches { get; set; } | ||
|
||
} | ||
|
||
public class BranchOptions | ||
{ | ||
public string Name { get; set; } | ||
|
||
[YamlMember(Alias = "minimum-reviewers", ApplyNamingConventions = false)] | ||
public int MinimumReviewers { get; set; } | ||
|
||
[YamlMember(Alias = "approve-own-changes", ApplyNamingConventions = false)] | ||
public bool ApproveOwnChanges { get; set; } | ||
|
||
[YamlMember(Alias = "complete-if-not-approved", ApplyNamingConventions = false)] | ||
public bool CompleteIfNotApproved { get; set; } | ||
|
||
[YamlMember(Alias = "reset-votes-on-new-change", ApplyNamingConventions = false)] | ||
public bool ResetVotesOnNewChange { get; set; } | ||
|
||
[YamlMember(Alias = "automatic-reviewers", ApplyNamingConventions = false)] | ||
public string[] AutomaticReviewers { get; set; } | ||
|
||
[YamlMember(Alias = "linked-work-items", ApplyNamingConventions = false)] | ||
public string LinkedWorkItems { get; set; } | ||
|
||
[YamlMember(Alias = "comment-resolution", ApplyNamingConventions = false)] | ||
public string CommentResolution { get; set; } | ||
|
||
[YamlMember(Alias = "merge-strategy", ApplyNamingConventions = false)] | ||
public string MergeStrategy { get; set; } | ||
|
||
// # build: TDB | ||
// # external-services: TBD | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
<RootNamespace>azdo_init</RootNamespace> | ||
<PackAsTool>true</PackAsTool> | ||
<ToolCommandName>azdo-init</ToolCommandName> | ||
<PackageOutputPath>./nupkg</PackageOutputPath> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="YamlDotNet" Version="5.3.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Include="template.yml" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '1.0' | ||
|
||
# [required] Your TFS or Azure DevOps instance URL | ||
account: ${AzureDevOpsCollectionUrl} | ||
|
||
# [optional] Your Team Project name. Defaults to current directory name. | ||
# project: ${TeamProjectName} | ||
|
||
# [optional] Repository Name. Defaults to current directory name. | ||
# repository: ${RepositoryName} | ||
|
||
# For branches, all values are optional and if not supplied are turned off. | ||
# boolean like values interpreted per https://yaml.org/type/bool.html | ||
# integer values interpreted per https://yaml.org/type/int.html | ||
|
||
branches: | ||
- name: master | ||
# minimum-reviewers: 2 # !!int = 0 | ||
# approve-own-changes: true # !!bool = false | ||
# complete-if-not-approved: true # !!bool = false | ||
# reset-votes-on-new-change: true # !!bool = false | ||
# automatic-reviewers: | ||
# - burtonrodman # string, and identity that can be resolved in the account | ||
# linked-work-items: ignore|warn|required # string = ignore | ||
# comment-resolution: ignore|warn|required # string = ignore | ||
# merge-strategy: none|squash|no-fast-forward # string = none | ||
# build: TDB | ||
# external-services: TBD | ||
|
||
- name: develop |