コード例 #1
0
        public CommitDetailsViewModel(Repository repository, RepositoryNavigationRequest request, Commit commit)
            : this(repository, new RepositoryNavigationRequest(request) { Treeish = commit.Hash })
        {
            CurrentCommit = new CommitViewModel(repository, request, commit, true);

            foreach (var change in commit.Changes)
            {
                // PASTE-START : borrowed from GitSharp.Demo
                var a = (change.ReferenceObject != null ? (change.ReferenceObject as Blob).RawData : new byte[0]);
                var b = (change.ComparedObject != null ? (change.ComparedObject as Blob).RawData : new byte[0]);

                a = (Diff.IsBinary(a) == true ? Encoding.ASCII.GetBytes("Binary content\nFile size: " + a.Length) : a);
                b = (Diff.IsBinary(b) == true ? Encoding.ASCII.GetBytes("Binary content\nFile size: " + b.Length) : b);
                // PASTE-END : borrowed from GitSharp.Demo

                var diff = new Diff(a, b);
                Changes.Add(new ChangeViewModel(request, change, diff));
            }
        }
コード例 #2
0
        public void FillFromRepository(Repository repository, RepositoryNavigationRequest request)
        {
            Branches.AddRange(repository.Branches.Keys.Select(x =>
                new BranchViewModel(x, new RepositoryNavigationRequest()
                {
                    RepositoryName = request.RepositoryName,
                    Treeish = x,
                    RepositoryLocation = request.RepositoryLocation
                })));

            Tags.AddRange(repository.Tags.Keys.Select(x =>
                new BranchViewModel(x, new RepositoryNavigationRequest()
                {
                    RepositoryName = request.RepositoryName,
                    Treeish = x,
                    RepositoryLocation = request.RepositoryLocation
                })));

            var obj = repository.Get<AbstractObject>(Treeish);

            if (obj.IsTag)
            {
                obj = (obj as Tag).Target;
            }

            if (obj.IsCommit)
            {
                CurrentCommit = new CommitViewModel(repository, request, obj as Commit, true);
            }
        }