Ejemplo n.º 1
0
        private void AddCommit(MCommit commit, GitCommit gitCommit)
        {
            //string subject = gitCommit.Subject;
            string tickets = "";             // GetTickets(subject);

            commit.Tickets = tickets;

            // Pre-create all parents
            commit.ParentIds.ForEach(pid => commit.Repository.Commit(pid));

            SetChildOfParents(commit);
            commit.IsSet = true;
        }
Ejemplo n.º 2
0
        private void AddVirtualEmptyCommit(MRepository repository)
        {
            CommitSha virtualSha = CommitSha.NoCommits;
            CommitId  virtualId  = new CommitId(virtualSha);

            GitCommit gitCommit = new GitCommit(
                virtualSha,
                "<Repository with no commits yet ...>",
                "<Repository with no commits yet ...>",
                "",
                DateTime.Now,
                DateTime.Now,
                new List <CommitId>());

            repository.GitCommits[virtualId] = gitCommit;
        }
Ejemplo n.º 3
0
        private static void TrySetBranchNameFromSubject(
            CommitId commitId,
            GitCommit gitCommit,
            IDictionary <CommitId, BranchName> branchNameByCommitId,
            IDictionary <CommitId, BranchName> subjectBranchNameByCommitId)
        {
            // Trying to parse source and target branch names from subject. They can be like
            // "Merge branch 'branch-name' of remote-repository-path"
            // This is considered a "pull merge", where branch-name is both source and target. These are
            // usually automatically created by tools and thus more trustworthy.
            // Other merge merge subjects are less trustworthy since they sometiems are manually edited
            // like:
            // "Merge source-branch"
            // which contains a source branch name, but sometimes they contain a target like
            // "Merge source-branch into target-branch"
            MergeBranchNames mergeNames = BranchNameParser.ParseBranchNamesFromSubject(gitCommit.Subject);

            if (IsPullMergeCommit(mergeNames))
            {
                // Pull merge subjects (source branch same as target) (trust worthy, so use branch name
                branchNameByCommitId[commitId] = mergeNames.SourceBranchName;
                branchNameByCommitId[gitCommit.ParentIds[0]] = mergeNames.SourceBranchName;
                branchNameByCommitId[gitCommit.ParentIds[1]] = mergeNames.SourceBranchName;

                // But also note the barnch name from subjects
                subjectBranchNameByCommitId[commitId] = mergeNames.SourceBranchName;
                subjectBranchNameByCommitId[gitCommit.ParentIds[0]] = mergeNames.SourceBranchName;
                subjectBranchNameByCommitId[gitCommit.ParentIds[1]] = mergeNames.SourceBranchName;
            }
            else
            {
                // Normal merge subject (less trustworthy)
                if (mergeNames.TargetBranchName != null)
                {
                    // There was a target branch name
                    subjectBranchNameByCommitId[commitId] = mergeNames.TargetBranchName;
                }

                if (mergeNames.SourceBranchName != null)
                {
                    // There was a source branch name
                    subjectBranchNameByCommitId[gitCommit.ParentIds[1]] = mergeNames.SourceBranchName;
                }
            }
        }
Ejemplo n.º 4
0
        private static void CopyToVirtualCommit
            (MRepository repository, MBranch branch, MCommit commit, CommitSha virtualSha)
        {
            GitCommit gitCommit = new GitCommit(
                virtualSha,
                branch.ParentCommit.Subject,
                branch.ParentCommit.Message,
                branch.ParentCommit.Author,
                branch.ParentCommit.AuthorDate,
                branch.ParentCommit.CommitDate + TimeSpan.FromSeconds(1),
                new List <CommitId> {
                branch.ParentCommitId
            });

            repository.GitCommits[commit.Id] = gitCommit;

            // commit.Id = GetId();
        }
Ejemplo n.º 5
0
        private static void CopyToUncommitedCommit(
            GitBranch currentBranch,
            MRepository repository,
            GitStatus status,
            MCommit commit,
            CommitId parentId)
        {
            int modifiedCount = status.AllChanges;
            int conflictCount = status.Conflicted;

            string subject = $"{modifiedCount} uncommitted changes in working folder";

            if (conflictCount > 0)
            {
                subject =
                    $"{conflictCount} conflicts and {modifiedCount} changes, {ShortSubject(status)}";
                commit.HasConflicts = true;
            }
            else if (status.IsMerging)
            {
                subject          = $"{modifiedCount} changes, {ShortSubject(status)}";
                commit.IsMerging = true;
            }

            GitCommit gitCommit = new GitCommit(
                CommitSha.Uncommitted,
                subject,
                subject,
                "",
                DateTime.Now,
                DateTime.Now,
                new List <CommitId> {
                parentId
            });

            repository.GitCommits[CommitId.Uncommitted] = gitCommit;

            commit.SetBranchName(currentBranch?.Name ?? "master");

            commit.Tickets  = "";
            commit.BranchId = null;
        }
Ejemplo n.º 6
0
 private static bool IsMergeCommit(GitCommit gitCommit)
 {
     return(gitCommit.ParentIds.Count > 1);
 }