Merge pull request 'Exception handling' (#7) from exceptionHandling into staging
Reviewed-on: #7
This commit is contained in:
commit
3582eae47c
@ -93,11 +93,19 @@ public class CommitDetail
|
|||||||
{
|
{
|
||||||
var branchResult = repo.Branches[branchName];
|
var branchResult = repo.Branches[branchName];
|
||||||
|
|
||||||
if (branchResult == null)
|
try
|
||||||
{
|
{
|
||||||
branchResult = repo.Branches[$"origin/{branchName}"];
|
if (branchResult == null)
|
||||||
var remoteBranch = repo.CreateBranch(branchName, branchResult.Tip);
|
{
|
||||||
repo.Branches.Update(remoteBranch, b => b.UpstreamBranch = $"refs/heads/{branchName}");
|
branchResult = repo.Branches[$"origin/{branchName}"];
|
||||||
|
var remoteBranch = repo.CreateBranch(branchName, branchResult.Tip);
|
||||||
|
repo.Branches.Update(remoteBranch, b => b.UpstreamBranch = $"refs/heads/{branchName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Cannot fetch {branchName} branch.");
|
||||||
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var c in branchResult.Commits)
|
foreach (var c in branchResult.Commits)
|
||||||
@ -120,29 +128,36 @@ public class CommitDetail
|
|||||||
{
|
{
|
||||||
using (var repo = new Repository(Directory.GetCurrentDirectory()))
|
using (var repo = new Repository(Directory.GetCurrentDirectory()))
|
||||||
{
|
{
|
||||||
var tagResult = repo.Tags[tagName].Target.Sha;
|
try
|
||||||
|
|
||||||
var commitFilter = new CommitFilter
|
|
||||||
{
|
{
|
||||||
IncludeReachableFrom = tagResult,
|
var tagResult = repo.Tags[tagName].Target.Sha;
|
||||||
};
|
|
||||||
|
var commitFilter = new CommitFilter
|
||||||
var query = repo.Commits.QueryBy(commitFilter);
|
|
||||||
|
|
||||||
foreach (var c in query)
|
|
||||||
{
|
|
||||||
if (!_authors.Contains(c.Author.Name))
|
|
||||||
{
|
{
|
||||||
_authors.Add(c.Author.Name);
|
IncludeReachableFrom = tagResult,
|
||||||
|
};
|
||||||
|
|
||||||
|
var query = repo.Commits.QueryBy(commitFilter);
|
||||||
|
|
||||||
|
foreach (var c in query)
|
||||||
|
{
|
||||||
|
if (!_authors.Contains(c.Author.Name))
|
||||||
|
{
|
||||||
|
_authors.Add(c.Author.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var a in _authors)
|
||||||
|
{
|
||||||
|
int commitCount = query.Where(r => r.Author.Name == a).Count();
|
||||||
|
_commitDetails.Add(a, commitCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (System.Exception)
|
||||||
foreach (var a in _authors)
|
|
||||||
{
|
{
|
||||||
int commitCount = query.Where(r => r.Author.Name == a).Count();
|
Console.WriteLine($"Cannot find the tag {tagName}");
|
||||||
_commitDetails.Add(a, commitCount);
|
Environment.Exit(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ static class Program
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.Console.WriteLine("This should not happen...");
|
System.Console.WriteLine("This should not happen...");
|
||||||
Environment.Exit(90);
|
Environment.Exit(4);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user