Example #1
0
 public void CreateOrResetBranch(string branchName, string startPoint)
 {
     using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
     {
         if (string.IsNullOrWhiteSpace(startPoint))
         {
             var branch = repo.GetOrCreateBranch(branchName);
             repo.Checkout(branch);
         }
         else
         {
             var commit = repo.Lookup <Commit>(startPoint);
             if (commit == null)
             {
                 throw new LibGit2Sharp.NotFoundException(string.Format("Start point \"{0}\" for reset was not found.", startPoint));
             }
             var branch = repo.GetOrCreateBranch(branchName);
             repo.Checkout(branch);
             repo.Reset(ResetMode.Hard, commit);
         }
     }
 }
Example #2
0
 public void CreateOrResetBranch(string branchName, string startPoint)
 {
     using (var repo = new LibGit2Sharp.Repository(RepositoryPath))
     {
         if (string.IsNullOrWhiteSpace(startPoint))
         {
             var branch = repo.GetOrCreateBranch(branchName);
             repo.Checkout(branch);
         }
         else
         {
             var commit = repo.Lookup<Commit>(startPoint);
             if (commit == null)
             {
                 throw new LibGit2Sharp.NotFoundException(string.Format("Start point \"{0}\" for reset was not found.", startPoint));
             }
             var branch = repo.GetOrCreateBranch(branchName);
             repo.Checkout(branch);
             repo.Reset(ResetMode.Hard, commit);
         }
     }
 }