public IEnumerable<ICommit> GetHistory(Project project, string id)
        {
            var repo = GetRepository(project);

            var branch = repo.Branches[id];
            yield return new GitCommit
            {
                Username = branch.CurrentCommit.Committer.Name,
                DateTime = branch.CurrentCommit.CommitDate.DateTime,
                Message = branch.CurrentCommit.Message,
                Id = branch.CurrentCommit.Hash,
                TreeId = branch.CurrentCommit.Tree.Hash,
                ParentIds = branch.CurrentCommit.HasParents ? branch.CurrentCommit.Parents.Select(p => p.Hash) : Enumerable.Empty<string>(),
                Changes = GetChanges(branch.CurrentCommit)
            };

            foreach (var ancestor in branch.CurrentCommit.Ancestors)
            {
                yield return new GitCommit
                {
                    Username = ancestor.Committer.Name,
                    DateTime = ancestor.CommitDate.DateTime,
                    Message = ancestor.Message,
                    Id = ancestor.Hash,
                    TreeId = ancestor.Tree.Hash,
                    ParentIds = ancestor.HasParents ? ancestor.Parents.Select(p => p.ShortHash) : Enumerable.Empty<string>(),
                    Changes = GetChanges(ancestor)
                };
            }
        }
        public IEnumerable<IBranch> GetBranches(Project project)
        {
            var repo = GetRepository(project);

            return repo.Branches.Select(b => new GitBranch
            {
                Name = b.Key,
                IsCurrent = b.Value.IsCurrent
            });
        }
 public void CreateRepository(Project project)
 {
     var cmd = new InitCommand
     {
         GitDirectory = Path.Combine(GitSettings.RepositoriesPath, project.Name),
         Quiet = false,
         Bare = true
     };
     cmd.Execute();
 }
        public ICommit GetCommit(Project project, string commitId)
        {
            var repo = GetRepository(project);

            var commit = repo.Get<Commit>(commitId);
            if (commit == null)
                return null;

            return new GitCommit
            {
                Username = commit.Committer.Name,
                DateTime = commit.CommitDate.DateTime,
                Message = commit.Message,
                Id = commit.Hash,
                TreeId = commit.Tree.Hash,
                ParentIds = commit.HasParents ? commit.Parents.Select(p => p.Hash) : Enumerable.Empty<string>(),
                Changes = GetChanges(commit)
            };
        }
Ejemplo n.º 5
0
 public ISourceObject GetSourceObject(Project project, string treeId, string path)
 {
     var provider = _sourceControlProviders.Single(x => x.Metadata.Name == project.SourceControlProvider);
     return provider.Value.GetSourceObject(project, treeId, path);
 }
Ejemplo n.º 6
0
 public ISourceControlProviderMetadata GetProviderMetadata(Project project)
 {
     return _sourceControlProviders.Single(x => x.Metadata.Name == project.SourceControlProvider).Metadata;
 }
Ejemplo n.º 7
0
 public IEnumerable<ICommit> GetHistory(Project project, string id)
 {
     var provider = _sourceControlProviders.Single(x => x.Metadata.Name == project.SourceControlProvider);
     return provider.Value.GetHistory(project, id);
 }
Ejemplo n.º 8
0
 public ICommit GetCommit(Project project, string commitId)
 {
     var provider = _sourceControlProviders.Single(x => x.Metadata.Name == project.SourceControlProvider);
     return provider.Value.GetCommit(project, commitId);
 }
Ejemplo n.º 9
0
 public IEnumerable<IBranch> GetBranches(Project project)
 {
     var provider = _sourceControlProviders.Single(x => x.Metadata.Name == project.SourceControlProvider);
     return provider.Value.GetBranches(project);
 }
        public ISourceObject GetSourceObject(Project project, string treeId, string path)
        {
            var repo = GetRepository(project);

            AbstractTreeNode node = null;
            if (repo.Branches.ContainsKey(treeId))
                node = repo.Branches[treeId].CurrentCommit.Tree;
            else
                node = repo.Get<AbstractObject>(treeId) as AbstractTreeNode;

            if (node == null)
                throw new NotSupportedException();

            if(!string.IsNullOrEmpty(path))
                node = GetNode(node, path.Split('/'));

            return CreateGitSourceObject(treeId, node);
        }
 private static Repository GetRepository(Project project)
 {
     return new Repository(Path.Combine(GitSettings.RepositoriesPath, project.Name + ".git"));
 }