本文整理汇总了C#中LibGit2Sharp.Repository.ApplyTag方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.ApplyTag方法的具体用法?C# Repository.ApplyTag怎么用?C# Repository.ApplyTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LibGit2Sharp.Repository
的用法示例。
在下文中一共展示了Repository.ApplyTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var result = CommandLine.Parser.Default.ParseArguments<Options>(args);
if (!result.Errors.Any())
{
string url = result.Value.Repository;
var brancOption = result.Value.Branch;
var branchSepIndex = brancOption.IndexOf('/');
if (branchSepIndex > 0)
{
var credentials = new UsernamePasswordCredentials
{
Username = result.Value.UserName,
Password = result.Value.Password
};
CredentialsHandler credHandler = (s, fromUrl, types) => credentials;
var remote = brancOption.Substring(0, branchSepIndex);
var branch = brancOption.Substring(branchSepIndex+1, brancOption.Length - branchSepIndex-1);
var workingDirectory = result.Value.LocalRepoPath;
var isLocalRepoExist = Repository.Discover(workingDirectory);
if (isLocalRepoExist == null)
{
var cloneOptions = new CloneOptions {CredentialsProvider = credHandler};
Repository.Clone(url, workingDirectory, cloneOptions);
}
Repository repo = null;
try
{
var tagName = result.Value.TagName;
repo = new Repository(workingDirectory);
//repo.Fetch(remote, new FetchOptions(){CredentialsProvider = credHandler});
repo.Network.Pull(new Signature(result.Value.UserName,result.Value.Email, new DateTimeOffset()),
new PullOptions() { FetchOptions = new FetchOptions() { CredentialsProvider = credHandler } });
repo.ApplyTag(tagName);
PushChanges(repo, credHandler, remote, branch, tagName);
Console.WriteLine("Tagged :{0}", result.Value.TagName);
}
catch (Exception ex)
{
Console.WriteLine("Error happened {0}", ex.Message);
}
finally
{
if (repo != null) repo.Dispose();
}
}
}
Console.ReadLine();
}
示例2: InitCoreTags
private void InitCoreTags(Repository repo)
{
// Create tags for Upvote, Downvote, and EmptyTree
Tree emptyTree = repo.ObjectDatabase.CreateTree(new TreeDefinition());
repo.ApplyTag(EMPTY_TREE, emptyTree.Sha);
Blob upvote = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.ASCII.GetBytes(UPVOTE)));
repo.ApplyTag(UPVOTE, upvote.Sha);
Blob downvote = repo.ObjectDatabase.CreateBlob(new MemoryStream(Encoding.ASCII.GetBytes(DOWNVOTE)));
repo.ApplyTag(DOWNVOTE, downvote.Sha);
}