Exemple #1
0
 public TreeEntryMock(Mode mode, string name, string path, TreeEntryTargetType targetType)
 {
     _mode       = mode;
     _name       = name;
     _path       = path;
     _targetType = targetType;
 }
Exemple #2
0
    internal Parts(string owner, string repository, TreeEntryTargetType type, string branch, string path, string sha)
    {
        Owner      = owner;
        Repository = repository;
        Type       = type;
        Branch     = branch;
        Path       = path;
        Sha        = sha;

        Url = string.Join("/", "https://github.com", owner, repository, type.ToString().ToLowerInvariant(), branch);

        if (path == null)
        {
            Name = null;
            NumberOfPathSegments = 0;
        }
        else
        {
            Url = string.Join("/", Url, path);
            var segments = path.Split('/');
            Name = segments.Last();
            NumberOfPathSegments = segments.Length;
        }

        parent = new Lazy <Parts>(BuildParent);
        root   = new Lazy <Parts>(BuildRoot);
    }
Exemple #3
0
 protected internal FileViewModel(Repository repo, string path, string name, GitObject obj, TreeEntryTargetType entryType)
 {
     Repository = repo;
     Path       = path;
     Name       = name;
     Object     = obj;
     EntryType  = entryType;
 }
Exemple #4
0
        public void RemoveSourceItem(TreeEntryTargetType type, string path, string target = null)
        {
            if (type == TreeEntryTargetType.Tree)
            {
                throw new NotSupportedException($"Removing a '{nameof(TreeEntryTargetType.Tree)}' isn't supported.");
            }

            AddOrRemoveSourceItem(false, type, path, target);
        }
Exemple #5
0
        static TreeEntry CreateTreeEntry(TreeEntryTargetType targetType, GitObject target, string path)
        {
            var treeEntry = Substitute.For <TreeEntry>();

            treeEntry.TargetType.Returns(targetType);
            treeEntry.Target.Returns(target);
            treeEntry.Path.Returns(path);
            return(treeEntry);
        }
        public void CanRetrieveEntries(string path, string expectedAttributes, TreeEntryTargetType expectedType, string expectedSha)
        {
            using (var repo = new Repository(BareTestRepoPath))
            {
                TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree);

                TreeEntryDefinition ted = td[path];

                Assert.Equal(ToMode(expectedAttributes), ted.Mode);
                Assert.Equal(expectedType, ted.TargetType);
                Assert.Equal(new ObjectId(expectedSha), ted.TargetId);
            }
        }
        public void CanRetrieveEntries(string path, string expectedAttributes, TreeEntryTargetType expectedType, string expectedSha)
        {
            using (var repo = new Repository(BareTestRepoPath))
            {
                TreeDefinition td = TreeDefinition.From(repo.Head.Tip.Tree);

                TreeEntryDefinition ted = td[path];

                Assert.Equal(ToMode(expectedAttributes), ted.Mode);
                Assert.Equal(expectedType, ted.TargetType);
                Assert.Equal(new ObjectId(expectedSha), ted.TargetId);
            }
        }
Exemple #8
0
        public static GitObjectType ToGitObjectType(this TreeEntryTargetType type)
        {
            switch (type)
            {
            case TreeEntryTargetType.Tree:
                return(GitObjectType.Tree);

            case TreeEntryTargetType.Blob:
                return(GitObjectType.Blob);

            default:
                throw new InvalidOperationException(string.Format("Cannot map {0} to a GitObjectType.", type));
            }
        }
        public void AddOrRemoveSourceItem(bool toBeAdded, TreeEntryTargetType type, string path, string target)
        {
            Guard.AgainstNullAndEmpty(path, nameof(path));
            Guard.AgainstEmpty(target, nameof(target));

            if (toBeAdded && syncMode == SyncMode.IncludeAllByDefault)
            {
                throw new NotSupportedException($"Adding items is not supported when mode is '{syncMode}'");
            }

            if (!toBeAdded && syncMode == SyncMode.ExcludeAllByDefault)
            {
                throw new NotSupportedException($"Adding items is not supported when mode is '{syncMode}'");
            }

            manualSyncItems.Add(new ManualSyncItem
            {
                Path = path
            });
        }
Exemple #10
0
 public Parts(string ownerRepository, TreeEntryTargetType type, string branch, string path)
     : this(ownerRepository.Split('/')[0], ownerRepository.Split('/')[1], type, branch, path, null)
 {
 }
Exemple #11
0
 internal Parts Combine(TreeEntryTargetType type, string name, string sha)
 {
     return(new Parts(Owner, Repository, type, Branch, Path == null ? name : Path + "/" + name, sha));
 }
Exemple #12
0
 public void AddSourceItem(TreeEntryTargetType type, string path, string target = null)
 {
     AddOrRemoveSourceItem(true, type, path, target);
 }
Exemple #13
0
        public static FileViewModel FromGitObject(Repository repo, string path, string name, GitObject obj, TreeEntryTargetType EntryType)
        {
            switch (repo.ObjectDatabase.RetrieveObjectMetadata(obj.Id).Type)
            {
            case ObjectType.Blob:
                return(new BlobModel(repo, path, name, (Blob)obj, EntryType));

            case ObjectType.Tree:
                return(new TreeModel(repo, path, name, (Tree)obj, EntryType));

            default:
                return(null);
            }
        }
Exemple #14
0
 public BlobModel(Repository repo, string path, string name, Blob obj, TreeEntryTargetType EntryType) : base(repo, path, name, obj, EntryType)
 {
 }
Exemple #15
0
 public TreeModel(Repository repo, string path, string name, Tree obj, TreeEntryTargetType EntryType, string parent = null) : base(repo, path, name, obj, EntryType)
 {
     Parent = parent;
 }