Ejemplo n.º 1
0
        public static string[] AddedOrModifiedFiles()
        {
            var headToc = Refs.Hash("HEAD") != null?Objects.CommitToc(Refs.Hash("HEAD")) : new Dictionary <string, string>();

            var wc = Diff.NameStatus(Diff.TocDiff(headToc, Index.WorkingCopyToc()));

            return(wc.Where(item => item.Value != FileStatus.DELETE).Select(item => item.Key).ToArray());
        }
Ejemplo n.º 2
0
        private static string[] ToBeCommitted()
        {
            var headHash = Refs.Hash("HEAD");
            var headToc  = headHash == null ? new Dictionary <string, string>() : Objects.CommitToc(headHash);
            var ns       = Diff.NameStatus(Diff.TocDiff(headToc, Index.Toc()));

            return(ns.Select(item => item.Value.Value + " " + item.Key).ToArray());
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets a list of files
        /// changed in the working copy.  It gets a list of the files that
        /// are different in the head commit and the commit for the passed
        /// hash.  It returns a list of paths that appear in both lists.
        /// </summary>
        public static string[] ChangedFilesCommitWouldOverwrite(string hash)
        {
            var headHash = Refs.Hash("HEAD");

            return
                (Diff.NameStatus(Diff.GetDiff(headHash)).Keys
                 .Intersect(Diff.NameStatus(Diff.GetDiff(headHash, hash)).Keys)
                 .ToArray());
        }
Ejemplo n.º 4
0
        public static string[] CommitParentHashes()
        {
            var headHash = Refs.Hash("HEAD");

            // If the repository is in the middle of a merge, return the
            // hashes of the two commits being merged.
            if (Merge.IsMergeInProgress())
            {
                return(new[] { headHash, Refs.Hash("MERGE_HEAD") });
            }

            // If this repository has no commits, return an empty array.
            if (headHash == null)
            {
                return(new string[0]);
            }

            // Otherwise, return the hash of the commit that `HEAD` is
            // currently pointing at.

            return(new[] { headHash });
        }
Ejemplo n.º 5
0
 /// <summary>
 /// returns true if the repository is in the middle of a merge.
 /// </summary>
 /// <returns></returns>
 public static bool IsMergeInProgress()
 {
     return(Refs.Hash("MERGE_HEAD") != null);
 }