예제 #1
0
파일: RepoUtil.cs 프로젝트: jez9999/Git-GUI
 /// <summary>
 /// Returns all branches that track the given branch.
 /// </summary>
 /// <param name="branch"></param>
 /// <returns></returns>
 public static IEnumerable<Branch> GetBranchesThatTrack(Branch branch, ObservableCollection<Branch> branches)
 {
     return branches.Where(b => b.TrackedBranch == branch);
 }
예제 #2
0
파일: Branch.cs 프로젝트: jez9999/Git-GUI
        /// <summary>
        /// Creates a new branch model.
        /// </summary>
        /// <returns></returns>
        public static Branch Create(RepositoryViewModel repositoryViewModel, LibGit2Sharp.Repository repo, LibGit2Sharp.Branch branch)
        {
            Branch newBranch = new Branch
            {
                CanonicalName = branch.CanonicalName,
                Name = branch.Name,
                IsRemote = branch.IsRemote,
                IsTracking = branch.IsTracking,
                TipHash = branch.Tip.Sha.ToString(),
                AheadBy = branch.AheadBy,
                BehindBy = branch.BehindBy,
                TrackedBranchName = branch.TrackedBranch != null ? branch.TrackedBranch.Name : null
            };

            newBranch.repositoryViewModel = repositoryViewModel;

            // Loop through the first N commits and let them know about me.
            foreach (LibGit2Sharp.Commit branchCommit in branch.Commits.Take(repositoryViewModel.CommitsPerPage))
            {
                Commit commit = repositoryViewModel.Commits.Where(c => c.Hash == branchCommit.Sha.ToString()).FirstOrDefault();

                if (commit != null)
                {
                    commit.Branches.Add(newBranch); // Let the commit know that I am one of her branches.

                    // Process commit DisplayTags (tags to display next to the commit description, in this case = branch Tips).
                    if (newBranch.TipHash == commit.Hash)
                    {
                        commit.DisplayTags.Add(branch.Name);
                        newBranch.Tip = commit;
                    }
                }
            }

            return newBranch;
        }