Пример #1
0
        public IEnumerable <ApplicableChange> GetChangesToApply()
        {
            if (DeletesProject)
            {
                return(Enumerable.Empty <ApplicableChange>());
            }

            if (RenameBranchCommmit)
            {
                return(new List <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 (IncludeInApply(change))
                    {
                        compartments.Updated.Add(ApplicableChange.Update(change.GitPath, change.Info.Mode));
                    }
                }
            }
            return(compartments.Deleted.Concat(compartments.Updated));
        }
Пример #2
0
 private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree)
 {
     var localPath = workspace.GetLocalPath(change.GitPath);
     if (File.Exists(localPath))
     {
         treeBuilder.Add(change.GitPath, localPath, change.Mode);
     }
     else
     {
         _stdout.WriteLine("Cannot checkout file '{0}' from TFS. Skip it", change.GitPath);
     }
 }
Пример #3
0
 private void Apply(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree)
 {
     switch (change.Type)
     {
         case ChangeType.Update:
             Update(change, treeBuilder, workspace, initialTree);
             break;
         case ChangeType.Delete:
             Delete(change.GitPath, treeBuilder, initialTree);
             break;
         default:
             throw new NotImplementedException("Unsupported change type: " + change.Type);
     }
 }
Пример #4
0
        public IEnumerable <ApplicableChange> GetChangesToApply()
        {
            var compartments = new {
                Deleted = new List <ApplicableChange>(),
                Updated = new List <ApplicableChange>(),
            };

            foreach (var change in NamedChanges)
            {
                if (change.Change.Item.ItemType == TfsItemType.File)
                {
                    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 (Include(change))
                        {
                            compartments.Updated.Add(ApplicableChange.Update(change.GitPath, oldInfo.Try(x => x.Mode, () => Mode.NonExecutableFile)));
                        }
                    }
                    else
                    {
                        if (Include(change))
                        {
                            compartments.Updated.Add(ApplicableChange.Update(change.GitPath, change.Info.Mode));
                        }
                    }
                }
            }
            return(compartments.Deleted.Concat(compartments.Updated));
        }
Пример #5
0
 private void Update(ApplicableChange change, IGitTreeModifier treeBuilder, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree)
 {
     treeBuilder.Add(change.GitPath, workspace.GetLocalPath(change.GitPath), change.Mode);
 }