コード例 #1
0
        public void AspNetDocModified()
        {
            var documento = new GitHubHostedDocument();
            documento.Commit = "5e6f9037bb7acf4411bf9e0320b0c5383692ef42";
            documento.FileName = "aspnet/index.rst";
            documento.Organization = "aspnet";
            documento.Repository = "Docs";
            documento.Status = "modified";
            documento.TsCommit = new DateTime(2015, 08, 27, 00, 02, 12);
            var messaggio = documento.GetTwitterText();

            Assert.AreEqual("[doc update]: index http://docs.asp.net/en/latest/index.html", messaggio);
        }
コード例 #2
0
        public void DotNetCoreDoc()
        {
            var documento = new GitHubHostedDocument();
            documento.Commit = "f3786b9c554b6d84a88382cf7deea3294a92e61a";
            documento.FileName = "docs/getting-started/installing-core-linux.rst";
            documento.Organization = "dotnet";
            documento.Repository = "core-docs";
            documento.Status = "modified";
            documento.TsCommit = new DateTime(2015, 06, 30, 13, 55, 46);
            var messaggio = documento.GetTwitterText();

            Assert.AreEqual("[doc update]: installing-core-linux http://dotnet.readthedocs.org/en/latest/getting-started/installing-core-linux.html", messaggio);
        }
コード例 #3
0
        public void EntityFrameworkDoc()
        {
            var documento = new GitHubHostedDocument();
            documento.Commit = "c5da04b8e571563eb68b8e4c893351288286f4cf";
            documento.FileName = "docs/getting-started/x-plat/guide.rst";
            documento.Organization = "aspnet";
            documento.Repository = "EntityFramework.Docs";
            documento.Status = "modified";
            documento.TsCommit = new DateTime(2015, 07, 29, 22, 59, 25);
            var messaggio = documento.GetTwitterText();

            Assert.AreEqual("[doc update]: guide http://ef.readthedocs.org/en/latest/getting-started/x-plat/guide.html", messaggio);
        }
コード例 #4
0
        public async Task<IList<GitHubHostedDocument>> ExtractCommitDocuments(string organization, string repository) {
            if (string.IsNullOrWhiteSpace(organization))
                throw new ArgumentNullException(nameof(organization), "must be specified");
            if (string.IsNullOrWhiteSpace(repository))
                throw new ArgumentNullException(nameof(repository), "must be specified");

            var client = GetClient();
            var documents = new List<GitHubHostedDocument>();

            Octokit.CommitRequest request = new Octokit.CommitRequest();
            request.Since = this.Settings.Since;
            request.Sha = "master";

            // get all the latest commits for the master branch 
            var commits = await client.Repository.Commits.GetAll(organization, repository, request);
            // recover the data of the branch looking for the master
            var repo = await client.Repository.GetBranch(organization, repository, "master");

            var head = repo.Commit.Sha;

            foreach (var currentCommit in commits) {
                //var compareResult = await client.Repository.Commits.Compare(organization, repository, currentCommit.Sha, head);
                //head = currentCommit.Sha;

                var myCommit = await client.Repository.Commits.Get(organization, repository, currentCommit.Sha);
                if (myCommit.Files != null) {
                    Console.WriteLine(myCommit.Files.Count.ToString());

                    foreach (var file in myCommit.Files)
                    {
                        if (file.Filename.ToLower().EndsWith(".rst", StringComparison.Ordinal))
                        {
                            var fileData = new GitHubHostedDocument();
                            fileData.Commit = currentCommit.Sha;
                            fileData.FileName = file.Filename;
                            fileData.Status = file.Status;
                            fileData.TsCommit = currentCommit.Commit.Committer.Date;
                            fileData.Organization = organization;
                            fileData.Repository = repository;

                            documents.Add(fileData);
                        }
                    }

                }

            }
            return documents;
        }