示例#1
0
        /// <returns>the commit if we had to do a commit, otherwise null</returns>
        /// <exception cref="NGit.Api.Errors.GitAPIException">NGit.Api.Errors.GitAPIException
        ///     </exception>
        /// <exception cref="System.IO.IOException">System.IO.IOException</exception>
        private RevCommit ContinueRebase()
        {
            // if there are still conflicts, we throw a specific Exception
            DirCache dc = repo.ReadDirCache();
            bool     hasUnmergedPaths = dc.HasUnmergedPaths();

            if (hasUnmergedPaths)
            {
                throw new UnmergedPathsException();
            }
            // determine whether we need to commit
            TreeWalk treeWalk = new TreeWalk(repo);

            treeWalk.Reset();
            treeWalk.Recursive = true;
            treeWalk.AddTree(new DirCacheIterator(dc));
            ObjectId id = repo.Resolve(Constants.HEAD + "^{tree}");

            if (id == null)
            {
                throw new NoHeadException(JGitText.Get().cannotRebaseWithoutCurrentHead);
            }
            treeWalk.AddTree(id);
            treeWalk.Filter = TreeFilter.ANY_DIFF;
            bool needsCommit = treeWalk.Next();

            treeWalk.Release();
            if (needsCommit)
            {
                CommitCommand commit = new Git(repo).Commit();
                commit.SetMessage(ReadFile(rebaseDir, MESSAGE));
                commit.SetAuthor(ParseAuthor());
                return(commit.Call());
            }
            return(null);
        }