示例#1
0
 /// <summary>
 /// Compares 2 GitBranchInfo objects to see if they are the same.  This occurs when there
 /// is a local copy and a remote of the same branch.  They have different names, but everything
 /// else is the same.
 /// </summary>
 /// <param name="b"></param>
 /// <returns></returns>
 public bool IsSameAs(GitBranchInfo b, Verbosity verbosity)
 {
     if (LatestCommitOnBranch == b.LatestCommitOnBranch &&
         LatestSemVersionOnBranch == b.LatestSemVersionOnBranch)
     {
         return(true);
     }
     return(false);
 }
示例#2
0
文件: SlugCI.cs 项目: SlugEnt/SlugCI
        /// <summary>
        /// Retrieves information about all the branches (local and remote).  It removes
        /// remote branches that are the exact same as local CISession.GitBranches.  At this point in the
        /// process this should result in all remote branches that have local counterparts
        /// being removed from our processing lists.
        /// </summary>
        private async Task GetBranchInfoAsync()
        {
            List <RecordBranchLatestCommit> latestCommits;


            latestCommits = CISession.GitProcessor.GetAllBranchesWithLatestCommit();
            foreach (RecordBranchLatestCommit recordBranchLatestCommit in latestCommits)
            {
                GitBranchInfo branch = new GitBranchInfo(recordBranchLatestCommit, CISession.GitProcessor);
                CISession.GitBranches.Add(branch.Name, branch);
            }

            // Process the Dictionary and remove the remotes that are exact same as locals
            List <string> branchesToRemove = new List <string>();

            foreach (KeyValuePair <string, GitBranchInfo> branch in CISession.GitBranches)
            {
                if (branch.Value.Name.StartsWith("remotes/origin"))
                {
                    string searchName = branch.Value.Name.Substring(15);
                    if (CISession.GitBranches.ContainsKey(searchName))
                    {
                        GitBranchInfo b = CISession.GitBranches[searchName];
                        if (branch.Value.IsSameAs(b, CISession.VerbosityCalcVersion))
                        {
                            branchesToRemove.Add(branch.Value.Name);
                        }
                    }
                }
            }

            foreach (string s in branchesToRemove)
            {
                CISession.GitBranches.Remove(s);
            }
        }