Пример #1
0
        /// <summary>
        /// Get all the changes of a changeset to apply
        /// </summary>
        /// <param name="forceGetChanges">true - force get changes ignoring check what should be applied. </param>
        public IEnumerable <ApplicableChange> GetChangesToApply(bool forceGetChanges = false)
        {
            if (DeletesProject)
            {
                return(Enumerable.Empty <ApplicableChange>());
            }

            var compartments = new
            {
                Deleted = new List <ApplicableChange>(),
                Updated = new List <ApplicableChange>(),
            };

            foreach (var change in NamedChanges)
            {
                // We only need the file changes because git only cares about files and if you make
                // changes to a folder in TFS, the changeset includes changes for all the descendant files anyway.
                if (change.Change.Item.ItemType != TfsItemType.File)
                {
                    continue;
                }

                if (change.Change.ChangeType.IncludesOneOf(TfsChangeType.Delete))
                {
                    if (change.GitPath != null)
                    {
                        compartments.Deleted.Add(ApplicableChange.Delete(change.GitPath));
                    }
                }
                else if (change.Change.ChangeType.IncludesOneOf(TfsChangeType.Rename))
                {
                    var oldInfo = _resolver.GetGitObject(GetPathBeforeRename(change.Change.Item));
                    if (oldInfo != null)
                    {
                        compartments.Deleted.Add(ApplicableChange.Delete(oldInfo.Path));
                    }
                    if (IncludeInApply(change))
                    {
                        compartments.Updated.Add(ApplicableChange.Update(change.GitPath,
                                                                         oldInfo != null ? oldInfo.Mode : Mode.NonExecutableFile));
                    }
                }
                else
                {
                    if (forceGetChanges || IncludeInApply(change))
                    {
                        // for get changes only on first change set
                        forceGetChanges = false;

                        compartments.Updated.Add(ApplicableChange.Update(change.GitPath, change.Info.Mode));
                    }
                }
            }
            return(compartments.Deleted.Concat(compartments.Updated));
        }
Пример #2
0
        /// <summary>
        /// Get all the changes of a changeset to apply
        /// </summary>
        public IEnumerable <ApplicableChange> GetChangesToApply()
        {
            if (DeletesProject)
            {
                return(Enumerable.Empty <ApplicableChange>());
            }

            var compartments = new
            {
                Deleted = new List <ApplicableChange>(),
                Updated = new List <ApplicableChange>(),
                Ignored = new List <ApplicableChange>(),
            };

            foreach (var change in NamedChanges)
            {
                // We only need the file changes because git only cares about files and if you make
                // changes to a folder in TFS, the changeset includes changes for all the descendant files anyway.
                if (change.Change.Item.ItemType != TfsItemType.File)
                {
                    continue;
                }

                if (change.Change.ChangeType.IncludesOneOf(TfsChangeType.Delete))
                {
                    if (!IsGitPathMissing(change))
                    {
                        compartments.Deleted.Add(ApplicableChange.Delete(change.GitPath));
                    }
                }
                else
                {
                    var mode = change.Info != null ? change.Info.Mode : Mode.NonExecutableFile;

                    if (change.Change.ChangeType.IncludesOneOf(TfsChangeType.Rename))
                    {
                        var oldInfo = _resolver.GetGitObject(GetPathBeforeRename(change.Change.Item));
                        if (oldInfo != null)
                        {
                            compartments.Deleted.Add(ApplicableChange.Delete(oldInfo.Path));

                            mode = oldInfo.Mode;
                        }
                    }

                    if (!IsItemDeleted(change) &&
                        !IsGitPathMissing(change) &&
                        !IsGitPathInDotGit(change) &&
                        !IsIgnorable(change))
                    {
                        if (IsGitPathIgnored(change))
                        {
                            compartments.Ignored.Add(ApplicableChange.Ignore(change.GitPath));
                        }
                        else
                        {
                            compartments.Updated.Add(ApplicableChange.Update(change.GitPath, mode));
                        }
                    }
                }
            }
            return(compartments.Deleted.Concat(compartments.Updated).Concat(compartments.Ignored));
        }