public GitActionResult<GitBranchInfo> CreateBranch(string branchName, string commitish = "HEAD")
{
var result = new GitActionResult<GitBranchInfo>();
try
{
using (var repository = GetRepository())
{
var branch = repository.CreateBranch(branchName, commitish);
if (branch != null)
{
result.Item = new GitBranchInfo
{
CanonicalName = branch.CanonicalName,
RemoteName = branch.Remote?.Name,
Name = branch.FriendlyName,
IsRemote = branch.IsRemote
};
result.Succeeded = true;
}
else
{
result.Succeeded = false;
}
}
}
catch (Exception ex)
{
result.ErrorMessage = ex.Message;
result.Succeeded = false;
}
return result;
}