/// <summary> /// Constructor /// </summary> public GitBranchInfo(RecordBranchLatestCommit branchRecord, GitProcessor gitProcessor) { Name = branchRecord.branch; // Retrieve info about the latest commit on the branch if (branchRecord.commitHash != "->") { LatestCommitOnBranch = gitProcessor.GetCommitInfo(branchRecord.commitHash); } LatestSemVersionOnBranch = gitProcessor.FindLatestSemVersionOnBranch(Name); }
/// <summary> /// Retrieves information about all branches and their latest commit. /// </summary> /// <param name="refresh"></param> /// <returns></returns> public List <RecordBranchLatestCommit> GetAllBranchesWithLatestCommit(bool refresh = false) { if (AllBranchInfo.Count != 0 && refresh == false) { return(AllBranchInfo); } List <LineOutColored> gitOutput; string gitArgs = "branch --sort=-committerdate --all -vv"; ExecuteGitTryCatch("GetAllBranchesWithLatestCommit", gitArgs, out gitOutput); List <RecordBranchLatestCommit> results = new List <RecordBranchLatestCommit>(); if (gitOutput.Count == 0) { return(results); } // Convert output into record results foreach (LineOutColored output in gitOutput) { RecordBranchLatestCommit record; if (output.Text.Substring(0, 1) == "*") { string [] elements = output.Text.Substring(2).Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); record = new RecordBranchLatestCommit(true, elements [0], elements [1], elements [2]); } else { string [] elements = output.Text.Trim().Split(' ', 3, StringSplitOptions.RemoveEmptyEntries); record = new RecordBranchLatestCommit(false, elements [0], elements [1], elements [2]); } results.Add(record); } AllBranchInfo = results; return(results); }