Exemplo n.º 1
0
        public LogEntry Apply(string lastCommit, GitIndexInfo index, TfsFailTracker failTracker)
        {
            var initialTree = Summary.Remote.Repository.GetObjects(lastCommit);

            // If you make updates to a dir in TF, the changeset includes changes for all the children also,
            // and git doesn't really care if you add or delete empty dirs.
            var fileChanges = changeset.Changes.Where(c => c.Item.ItemType == ItemType.File);

            foreach(var change in fileChanges)
            {
                ApplyDelete(change, index, initialTree, failTracker);
            }

            foreach (var change in fileChanges)
            {
                ApplyAdds(change, index, initialTree);
            }

            return MakeNewLogEntry();
        }
Exemplo n.º 2
0
        public void CanRecordFailureForChange()
        {
            long changesetId = 123;

            ChangeType changeType = ChangeType.Rename;
            string serverPath = @"$\tfs\some\file.cs";
            string reason = "unable to delete rename source";

            TfsFailTracker sut = new TfsFailTracker();

            sut.TrackFailureLoadingChange(changesetId, changeType, serverPath, reason);

            var results = sut.GetSummary();

            var expectedResult =
                "Error loading changeset " + changesetId.ToString() + "\r\n" +
                "    " + reason + " for Rename of " + serverPath + "\r\n";

            Assert.AreEqual(expectedResult, results);
        }
Exemplo n.º 3
0
        public void TrackFailureLoadingChangeset()
        {
            long changesetId = 123;

            string message = "someMessage";
            string stacktrace = "    at Foo\n    at Bar";
            FakeException someException = new FakeException(message, stacktrace);

            TfsFailTracker sut = new TfsFailTracker();

            sut.TrackFailureLoadingChangeset(changesetId, someException);

            var results = sut.GetSummary();

            string expectedResult =   "Error loading changeset " + changesetId.ToString() + "\r\n" +
                                      "    Message: " + message + "\r\n" +
                                      "        at Foo\r\n" +
                                      "        at Bar\r\n";
            Assert.AreEqual(
                expectedResult, results);
        }
Exemplo n.º 4
0
        public void InitiallyEmpty()
        {
            TfsFailTracker sut = new TfsFailTracker();

            var errorNotes = sut.GetSummary();

            Assert.AreEqual(null, errorNotes);
        }
Exemplo n.º 5
0
        void FlushFailRecordsToNote(string commit, TfsFailTracker failTracker)
        {
            string failRecord = failTracker.GetSummary();

            if (failRecord != null)
            {
                string note = Repository.GetNote(commit);

                if (note == null)
                    note = failRecord;
                else
                    note = note + "\n" + failRecord;

                Repository.SetNote(commit, note);

                failTracker.Reset();
            }
        }
Exemplo n.º 6
0
        public IEnumerable<ITfsChangeset> GetAllChangesetsStartingAt(long startChangeset, TfsFailTracker failTracker)
        {
            long position = startChangeset;
            Changeset changeset = null;

            do
            {
                try
                {
                    changeset = VersionControl.GetChangeset((int) position, true, true);
                }
                catch(Exception e)
                {
                    if (TfsFailTracker.ShouldHaltOnError(e))
                        throw;

                    failTracker.TrackFailureLoadingChangeset(position, e);
                }

                if (changeset != null)
                    yield return new TfsChangeset(this, changeset)
                    {
                        Summary = new TfsChangesetInfo { ChangesetId = changeset.ChangesetId }
                    };

                position++;

            } while (changeset != null);
        }
Exemplo n.º 7
0
        void ApplyDelete(Change change, GitIndexInfo index, IDictionary<string, GitObject> initialTree, TfsFailTracker failTracker)
        {
            if (change.Item.DeletionId != 0)
            {
                string oldPath = null;

                try
                {
                    oldPath = Summary.Remote.GetPathInGitRepo(GetPathBeforeRename(change.Item));
                } catch (Exception e)
                {
                    failTracker.TrackFailureLoadingChange(change.Item.ChangesetId, change.ChangeType, change.Item.ServerItem, "Unable to locate deleted item");
                }

                if (oldPath != null)
                {
                    Delete(oldPath, index, initialTree);
                }
            }
        }