Ejemplo n.º 1
0
		/// <param name="diff"></param>
		public Status(IndexDiff diff) : base()
		{
			this.diff = diff;
			clean = diff.GetAdded().IsEmpty() && diff.GetChanged().IsEmpty() && diff.GetRemoved
				().IsEmpty() && diff.GetMissing().IsEmpty() && diff.GetModified().IsEmpty() && diff
				.GetUntracked().IsEmpty() && diff.GetConflicting().IsEmpty();
		}
Ejemplo n.º 2
0
        public virtual void TestRemovedUntracked()
        {
            Git    git  = new Git(db);
            string path = "file";

            WriteTrashFile(path, "content");
            git.Add().AddFilepattern(path).Call();
            git.Commit().SetMessage("commit").Call();
            RemoveFromIndex(path);
            FileTreeIterator iterator = new FileTreeIterator(db);
            IndexDiff        diff     = new IndexDiff(db, Constants.HEAD, iterator);

            diff.Diff();
            NUnit.Framework.Assert.IsTrue(diff.GetRemoved().Contains(path));
            NUnit.Framework.Assert.IsTrue(diff.GetUntracked().Contains(path));
        }
        public GitFileStatus GetFileStatusNoCache(string fileName)
        {
            //Debug.WriteLine(string.Format("===+ GetFileStatusNoCache {0}", fileName));

            var fileNameRel = GetRelativeFileNameForGit(fileName);

            IndexDiff indexDiff = new IndexDiff(repository, Constants.HEAD, new FileTreeIterator(repository));
            indexDiff.SetFilter(PathFilterGroup.CreateFromStrings(fileNameRel));
            indexDiff.Diff();

            if (indexDiff.GetModified().Count > 0)
                return GitFileStatus.Modified;

            if (indexDiff.GetConflicting().Count > 0)
                return GitFileStatus.Conflict;

            if (indexDiff.GetUntracked().Count > 0 || indexDiff.GetUntrackedFolders().Count > 0)
            {
                if (File.Exists(fileName))
                    return GitFileStatus.New;

                return GitFileStatus.NotControlled;
            }

            if (indexDiff.GetAdded().Count > 0)
                return GitFileStatus.Added;

            if (!File.Exists(fileName))
            {
                if (indexDiff.GetMissing().Count > 0)
                    return GitFileStatus.Removed;

                return GitFileStatus.Deleted;
            }

            if (indexDiff.GetChanged().Count > 0)
                return GitFileStatus.Staged;

            if (indexDiff.GetIgnoredNotInIndex().Count > 0)
                return GitFileStatus.Ignored;

            return GitFileStatus.Tracked;
        }
Ejemplo n.º 4
0
 public virtual void TestRemovedUntracked()
 {
     Git git = new Git(db);
     string path = "file";
     WriteTrashFile(path, "content");
     git.Add().AddFilepattern(path).Call();
     git.Commit().SetMessage("commit").Call();
     RemoveFromIndex(path);
     FileTreeIterator iterator = new FileTreeIterator(db);
     IndexDiff diff = new IndexDiff(db, Constants.HEAD, iterator);
     diff.Diff();
     NUnit.Framework.Assert.IsTrue(diff.GetRemoved().Contains(path));
     NUnit.Framework.Assert.IsTrue(diff.GetUntracked().Contains(path));
     NUnit.Framework.CollectionAssert.AreEquivalent(Collections<string>.EMPTY_SET, diff.GetUntrackedFolders()
         );
 }
Ejemplo n.º 5
0
        protected void RaiseNotifyFromDiff(Repository repository)
        {
            if (repository == null)
                throw new ArgumentNullException("repository");
            var workingTreeIt = new FileTreeIterator(repository);
            var diff = new IndexDiff(repository, Constants.HEAD, workingTreeIt);

            diff.Diff();

            RaiseNotifyFromDiff(repository, diff.GetAdded(), GitNotifyAction.UpdateAdd);
            RaiseNotifyFromDiff(repository, diff.GetAssumeUnchanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetChanged(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetConflicting(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetMissing(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetModified(), GitNotifyAction.UpdateUpdate);
            RaiseNotifyFromDiff(repository, diff.GetRemoved(), GitNotifyAction.UpdateDeleted);
            RaiseNotifyFromDiff(repository, diff.GetUntracked(), GitNotifyAction.UpdateUpdate);
        }