Exemple #1
0
 public static List <Ref> branches_Raw(this API_NGit nGit)
 {
     if (nGit.git().notNull())
     {
         try
         {
             var listBranches = nGit.git().BranchList();
             return(listBranches.Call().toList());
         }
         catch (Exception ex)
         {
             ex.log("[API_NGit][branches_Raw]");
         }
     }
     return(new List <Ref>());
 }
Exemple #2
0
 public static bool         branch_Delete(this API_NGit nGit, string branchName)
 {
     if (nGit.git().notNull() && branchName.notNull())
     {
         try
         {
             var deleteBranch = nGit.git().BranchDelete();
             deleteBranch.SetBranchNames(new [] { branchName });
             return(deleteBranch.Call().first().simple_BranchName() == branchName);
         }
         catch (Exception ex)
         {
             ex.log("[API_NGit][branch_Delete]");
         }
     }
     return(false);
 }
Exemple #3
0
 public static bool         branch_Rename(this API_NGit nGit, string branchName_Old, string branchName_New)
 {
     if (nGit.git().notNull())
     {
         try
         {
             var renameBranch = nGit.git().BranchRename();
             renameBranch.SetOldName(branchName_Old);
             renameBranch.SetNewName(branchName_New);
             return(renameBranch.Call().simple_BranchName() == branchName_New);
         }
         catch (Exception ex)
         {
             ex.log("[API_NGit][branch_Rename]");
         }
     }
     return(false);
 }
Exemple #4
0
 public static bool         branch_Create(this API_NGit nGit, string name)
 {
     if (nGit.git().notNull())
     {
         try
         {
             var createBranch = nGit.git().BranchCreate();
             createBranch.SetName(name);
             var @ref = createBranch.Call();
             return(@ref.simple_BranchName() == name);
         }
         catch (Exception ex)
         {
             ex.log("[API_NGit][Repository][branch_Create]");
         }
     }
     return(false);
 }
        public static bool fetch(this API_NGit nGit, string remote, string fromBranch, string toBranch)
        {
            if (nGit.git().notNull())
            {
                try
                {
                    nGit.Last_FetchResult = null;
                    nGit.Last_Exception   = null;
                    var fetchCommand = nGit.git().Fetch();
                    fetchCommand.SetRemote(remote);
                    var spec = new RefSpec("refs/heads/{0}:refs/heads/{1}".format(fromBranch, toBranch));
                    fetchCommand.SetRefSpecs(spec);

                    nGit.Last_FetchResult = fetchCommand.Call();
                    return(true);
                }
                catch (Exception ex)
                {
                    nGit.Last_Exception = ex;
                    ex.log("[API_NGit][fetch]");
                }
            }
            return(false);
        }
Exemple #6
0
 public static bool  reset_Hard(this API_NGit nGit)
 {
     try
     {
         var resetCommand = nGit.git().Reset();
         resetCommand.SetMode(ResetCommand.ResetType.HARD);
         nGit.Last_ResetResult = resetCommand.Call();
         "[API_NGit][reset_Hard] {0}".error(nGit.Last_ResetResult);
         return(true);
     }
     catch (Exception ex)
     {
         ex.log("[API_NGit][reset_Hard]");
         return(false);
     }
 }