Exemplo n.º 1
0
        public void Upload(Folder folderInfo)
        {
            var tree        = this.ConstructTree(folderInfo);
            var createdTree = client.Git.Tree.Create(repo.Id, tree);

            createdTree.Wait();


            // 4 - this commit should build on the current master branch
            var master = client.Git.Reference.Get(repo.Id, "heads/master");

            master.Wait();
            var newCommit = new NewCommit(
                "Hello World!",
                createdTree.Result.Sha,
                new[] { master.Result.Object.Sha })
            {
                Author = new Committer("ram", "*****@*****.**", DateTime.UtcNow)
            };



            var createdCommit = client.Git.Commit.Create(repo.Id, newCommit);

            createdCommit.Wait();

            // 5 - create a reference for the master branch

            var updateReference = new ReferenceUpdate(createdCommit.Result.Sha);

            var updatedReference = client.Git.Reference.Update(repo.Id, "heads/master", updateReference);

            updatedReference.Wait();
        }
 public UnusedReferencesEntry(string solutionName, string projectName, string language, ReferenceUpdate referenceUpdate)
 {
     SolutionName    = solutionName;
     ProjectName     = projectName;
     Language        = language;
     ReferenceUpdate = referenceUpdate;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Updates a reference for a given repository by reference name
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/refs/#update-a-reference
        /// </remarks>
        /// <param name="repositoryId">The Id of the repository</param>
        /// <param name="reference">The name of the reference</param>
        /// <param name="referenceUpdate">The updated reference data</param>
        /// <returns></returns>
        public IObservable <Reference> Update(long repositoryId, string reference, ReferenceUpdate referenceUpdate)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
            Ensure.ArgumentNotNull(referenceUpdate, "update");

            return(_reference.Update(repositoryId, reference, referenceUpdate).ToObservable());
        }
Exemplo n.º 4
0
        private async Task <Reference> PushFix(IGitHubClient client, Repository repository, Commit latest, string jenkinsFile)
        {
            var oldTree = await client.Git.Tree.Get(repository.Owner.Login, repository.Name, latest.Sha).ConfigureAwait(false);

            var newTree = new NewTree
            {
                BaseTree = oldTree.Sha
            };

            var blobReference = await CreateBlob(client, repository, jenkinsFile).ConfigureAwait(false);

            var treeItem = new NewTreeItem()
            {
                Path = JenkinsFileName,
                Mode = FileMode,
                Type = TreeType.Blob,
                Sha  = blobReference.Sha
            };

            newTree.Tree.Add(treeItem);

            var createdTree = await client.Git.Tree.Create(repository.Owner.Login, repository.Name, newTree).ConfigureAwait(false);

            var commit         = new NewCommit($"Update {LibraryName} to latest version.", createdTree.Sha, new[] { latest.Sha });
            var commitResponse = await client.Git.Commit.Create(repository.Owner.Login, repository.Name, commit).ConfigureAwait(false);

            var refUpdate = new ReferenceUpdate(commitResponse.Sha);

            return(await client.Git.Reference.Update(repository.Owner.Login, repository.Name, $"heads/{_branchName}", refUpdate).ConfigureAwait(false));
        }
Exemplo n.º 5
0
        internal async Task ApplyReferenceUpdates_NoChangeUpdates_AreNotApplied(UpdateAction action, bool treatAsUsed)
        {
            var noChangeUpdate = new ReferenceUpdate(action, PackageReference(UnusedAssemblyPath, treatAsUsed));

            var appliedUpdates = await ApplyReferenceUpdatesAsync(noChangeUpdate);

            Assert.Empty(appliedUpdates);
        }
Exemplo n.º 6
0
        internal async Task ApplyReferenceUpdates_ChangeUpdates_AreApplied(UpdateAction action, bool treatAsUsed)
        {
            var changeUpdate = new ReferenceUpdate(action, PackageReference(UnusedAssemblyPath, treatAsUsed));

            var appliedUpdates = await ApplyReferenceUpdatesAsync(changeUpdate);

            Assert.Contains(changeUpdate, appliedUpdates);
            Assert.Single(appliedUpdates);
        }
Exemplo n.º 7
0
        public async Task ApplyReferenceUpdates_MixOfChangeAndNoChangeUpdates_ChangesAreApplied()
        {
            var noChangeUpdate = new ReferenceUpdate(UpdateAction.None, PackageReference(UsedAssemblyPath));
            var changeUpdate   = new ReferenceUpdate(UpdateAction.Remove, PackageReference(UnusedAssemblyPath));

            var appliedUpdates = await ApplyReferenceUpdatesAsync(noChangeUpdate, changeUpdate);

            Assert.Contains(changeUpdate, appliedUpdates);
            Assert.Single(appliedUpdates);
        }
Exemplo n.º 8
0
            public async Task PostsToCorrectUrl()
            {
                var referenceUpdate = new ReferenceUpdate("sha");
                var connection      = Substitute.For <IApiConnection>();
                var client          = new ReferencesClient(connection);

                await client.Update("owner", "repo", "heads/develop", referenceUpdate);

                connection.Received().Patch <Reference>(Arg.Is <Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"), referenceUpdate);
            }
Exemplo n.º 9
0
            public void PostsToCorrectUrlWithRepositoryId()
            {
                var referenceUpdate = new ReferenceUpdate("sha");
                var gitHubClient    = Substitute.For <IGitHubClient>();
                var client          = new ObservableReferencesClient(gitHubClient);

                client.Update(1, "heads/develop", referenceUpdate);

                gitHubClient.Received().Git.Reference.Update(1, "heads/develop", referenceUpdate);
            }
Exemplo n.º 10
0
    public async Task CanUpdateAReference()
    {
        var firstBlob = new NewBlob
        {
            Content  = "Hello World!",
            Encoding = EncodingType.Utf8
        };
        var firstBlobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, firstBlob);

        var secondBlob = new NewBlob
        {
            Content  = "This is a test!",
            Encoding = EncodingType.Utf8
        };
        var secondBlobResult = await _client.GitDatabase.Blob.Create(_owner, _repository.Name, secondBlob);

        var firstTree = new NewTree();

        firstTree.Tree.Add(new NewTreeItem
        {
            Mode = FileMode.File,
            Type = TreeType.Blob,
            Path = "README.md",
            Sha  = firstBlobResult.Sha
        });

        var firstTreeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, firstTree);

        var firstCommit       = new NewCommit("This is a new commit", firstTreeResult.Sha);
        var firstCommitResult = await _client.GitDatabase.Commit.Create(_owner, _repository.Name, firstCommit);

        var newReference = new NewReference("heads/develop", firstCommitResult.Sha);
        await _fixture.Create(_owner, _repository.Name, newReference);

        var secondTree = new NewTree();

        secondTree.Tree.Add(new NewTreeItem
        {
            Mode = FileMode.File,
            Type = TreeType.Blob,
            Path = "README.md",
            Sha  = secondBlobResult.Sha
        });

        var secondTreeResult = await _client.GitDatabase.Tree.Create(_owner, _repository.Name, secondTree);

        var secondCommit       = new NewCommit("This is a new commit", secondTreeResult.Sha, firstCommitResult.Sha);
        var secondCommitResult = await _client.GitDatabase.Commit.Create(_owner, _repository.Name, secondCommit);

        var referenceUpdate = new ReferenceUpdate(secondCommitResult.Sha);

        var result = await _fixture.Update(_owner, _repository.Name, "heads/develop", referenceUpdate);

        Assert.Equal(secondCommitResult.Sha, result.Object.Sha);
    }
        public async Task <bool> TryUpdateReferenceAsync(string projectPath, ReferenceUpdate referenceUpdate, CancellationToken cancellationToken)
        {
            var operation = await _projectSystemReferenceUpdateService.GetUpdateReferenceOperationAsync(projectPath, referenceUpdate.ToProjectSystemReferenceUpdate(), cancellationToken).ConfigureAwait(true);

            if (operation is null)
            {
                return(false);
            }

            return(await operation.ApplyAsync(cancellationToken).ConfigureAwait(true));
        }
Exemplo n.º 12
0
        public async void UpdateReferencesAsync_UpdatePackages_NoAction()
        {
            var referenceCleanupService = Setup();

            var referenceUpdate1 =
                new ReferenceUpdate(UpdateAction.None, new ReferenceInfo(ReferenceType.Package, "", true));

            await referenceCleanupService.TryUpdateReferenceAsync(_projectPath1, "", referenceUpdate1, CancellationToken.None);

            _configuredProjectMock1.Verify(c => c.Services.PackageReferences.RemoveAsync(It.IsAny <string>()), Times.Never);
        }
Exemplo n.º 13
0
 public Task <bool> TryUpdateReferenceAsync(
     string projectPath,
     ReferenceUpdate referenceUpdate,
     CancellationToken cancellationToken
     )
 {
     return(_projectSystemReferenceUpdateService.TryUpdateReferenceAsync(
                projectPath,
                referenceUpdate.ToProjectSystemReferenceUpdate(),
                cancellationToken
                ));
 }
Exemplo n.º 14
0
        public static ProjectSystemReferenceUpdate ToProjectSystemReferenceUpdate(this ReferenceUpdate referenceUpdate)
        {
            var updateAction = referenceUpdate.Action switch
            {
                UpdateAction.TreatAsUsed => ProjectSystemUpdateAction.SetTreatAsUsed,
                UpdateAction.TreatAsUnused => ProjectSystemUpdateAction.UnsetTreatAsUsed,
                UpdateAction.Remove => ProjectSystemUpdateAction.Remove,
                _ => throw ExceptionUtilities.Unreachable
            };

            return(new ProjectSystemReferenceUpdate(
                       updateAction,
                       referenceUpdate.ReferenceInfo.ToProjectSystemReferenceInfo()));
        }
Exemplo n.º 15
0
        public async Task CommitAsync()
        {
            var owner         = "dotnet";
            var repo          = "apireviews";
            var branch        = "heads/master";
            var markdown      = $"# Quick Reviews {Date.ToString("d")}\n\n{GetMarkdown()}";
            var path          = $"{Date.Year}/{Date.Month:00}-{Date.Day:00}-quick-reviews/README.md";
            var commitMessage = $"Add quick review notes for {Date.ToString("d")}";

            var github          = GitHubClientFactory.Create();
            var masterReference = await github.Git.Reference.Get(owner, repo, branch);

            var latestCommit = await github.Git.Commit.Get(owner, repo, masterReference.Object.Sha);

            var recursiveTreeResponse = await github.Git.Tree.GetRecursive(owner, repo, latestCommit.Tree.Sha);

            var file = recursiveTreeResponse.Tree.SingleOrDefault(t => t.Path == path);

            if (file == null)
            {
                var newTreeItem = new NewTreeItem
                {
                    Mode    = "100644",
                    Path    = path,
                    Content = markdown
                };

                var newTree = new NewTree
                {
                    BaseTree = latestCommit.Tree.Sha
                };
                newTree.Tree.Add(newTreeItem);

                var newTreeResponse = await github.Git.Tree.Create(owner, repo, newTree);

                var newCommit         = new NewCommit(commitMessage, newTreeResponse.Sha, latestCommit.Sha);
                var newCommitResponse = await github.Git.Commit.Create(owner, repo, newCommit);

                var newReference         = new ReferenceUpdate(newCommitResponse.Sha);
                var newReferenceResponse = await github.Git.Reference.Update(owner, repo, branch, newReference);
            }
        }
Exemplo n.º 16
0
        /// <inheritdoc/>
        protected override async Task <object> CallGitHubApi(DialogContext dc, Octokit.GitHubClient gitHubClient, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (Owner != null && Name != null && Reference != null && ReferenceUpdate != null)
            {
                var ownerValue           = Owner.GetValue(dc.State);
                var nameValue            = Name.GetValue(dc.State);
                var referenceValue       = Reference.GetValue(dc.State);
                var referenceUpdateValue = ReferenceUpdate.GetValue(dc.State);
                return(await gitHubClient.Git.Reference.Update(ownerValue, nameValue, referenceValue, referenceUpdateValue).ConfigureAwait(false));
            }
            if (RepositoryId != null && Reference != null && ReferenceUpdate != null)
            {
                var repositoryIdValue    = RepositoryId.GetValue(dc.State);
                var referenceValue       = Reference.GetValue(dc.State);
                var referenceUpdateValue = ReferenceUpdate.GetValue(dc.State);
                return(await gitHubClient.Git.Reference.Update((Int64)repositoryIdValue, referenceValue, referenceUpdateValue).ConfigureAwait(false));
            }

            throw new ArgumentNullException("Required [reference,referenceUpdate] arguments missing for GitHubClient.Git.Reference.Update");
        }
Exemplo n.º 17
0
        private ReferenceHandler FindReferenceHandler(ReferenceUpdate referenceUpdate)
        {
            ReferenceHandler referenceHandler;

            if (referenceUpdate.ReferenceInfo.ReferenceType == ReferenceType.Project)
            {
                referenceHandler = _projectReferenceHandler;
            }
            else if (referenceUpdate.ReferenceInfo.ReferenceType == ReferenceType.Package)
            {
                referenceHandler = _packageReferenceHandler;
            }
            else if (referenceUpdate.ReferenceInfo.ReferenceType == ReferenceType.Assembly)
            {
                referenceHandler = _assemblyReferenceHandler;
            }
            else
            {
                referenceHandler = _sdkReferenceHandler;
            }

            return(referenceHandler);
        }
            public async Task PostsToCorrectUrl()
            {
                var referenceUpdate = new ReferenceUpdate("sha");
                var connection = Substitute.For<IApiConnection>();
                var client = new ReferencesClient(connection);

                await client.Update("owner", "repo", "heads/develop", referenceUpdate);

                connection.Received().Patch<Reference>(Arg.Is<Uri>(u => u.ToString() == "repos/owner/repo/git/refs/heads/develop"), referenceUpdate);
            }
Exemplo n.º 19
0
        public async Task <bool> TryUpdateReferenceAsync(string projectPath, string targetFrameworkMoniker, ReferenceUpdate referenceUpdate, CancellationToken cancellationToken)
        {
            bool wasUpdated = false;

            if (referenceUpdate.Action == UpdateAction.None)
            {
                return(wasUpdated);
            }

            ConfiguredProject activeConfiguredProject = await GetActiveConfiguredProjectByPathAsync(projectPath);

            ReferenceHandler referenceHandler = FindReferenceHandler(referenceUpdate);

            if (referenceUpdate.Action == UpdateAction.TreatAsUsed || referenceUpdate.Action == UpdateAction.TreatAsUnused)
            {
                wasUpdated = await referenceHandler.UpdateReferenceAsync(activeConfiguredProject, referenceUpdate, cancellationToken);
            }
            else
            {
                wasUpdated = await referenceHandler.RemoveReferenceAsync(activeConfiguredProject, referenceUpdate.ReferenceInfo);
            }

            return(wasUpdated);
        }
        /// <summary>
        /// Updates a reference for a given repository by reference name
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/refs/#update-a-reference
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="reference">The name of the reference</param>
        /// <param name="referenceUpdate">The updated reference data</param>
        /// <returns></returns>
        public IObservable<Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
            Ensure.ArgumentNotNull(referenceUpdate, "update");

            return _reference.Update(owner, name, reference, referenceUpdate).ToObservable();
        }
Exemplo n.º 21
0
        /// <summary>
        /// Updates a reference for a given repository by reference name
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/refs/#update-a-reference
        /// </remarks>
        /// <param name="owner">The owner of the repository</param>
        /// <param name="name">The name of the repository</param>
        /// <param name="reference">The name of the reference</param>
        /// <param name="referenceUpdate">The updated reference data</param>
        /// <returns></returns>
        public IObservable <Reference> Update(string owner, string name, string reference, ReferenceUpdate referenceUpdate)
        {
            Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
            Ensure.ArgumentNotNullOrEmptyString(name, "name");
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
            Ensure.ArgumentNotNull(referenceUpdate, "update");

            return(_reference.Update(owner, name, reference, referenceUpdate).ToObservable());
        }
            public async Task <bool> UpdateReferenceAsync(ConfiguredProject activeConfiguredProject, ReferenceUpdate referenceUpdate, CancellationToken cancellationToken)
            {
                bool wasUpdated = false;

                string projectPath = activeConfiguredProject.UnconfiguredProject.FullPath;

                string newValue = referenceUpdate.Action == UpdateAction.TreatAsUsed ? "True" : "False";

                await activeConfiguredProject.Services.ProjectLockService.WriteLockAsync(async access =>
                {
                    var projectOther = await access.GetProjectAsync(activeConfiguredProject, cancellationToken);

                    var item = projectOther.AllEvaluatedItems.Where(i =>
                                                                    string.Compare(i.ItemType, _schema, StringComparison.OrdinalIgnoreCase) == 0 &&
                                                                    i.EvaluatedInclude == referenceUpdate.ReferenceInfo.ItemSpecification).First();

                    if (item != null)
                    {
                        await access.CheckoutAsync(projectPath);

                        item.SetMetadataValue("TreatAsUsed", newValue);

                        wasUpdated = true;
                    }
                }, cancellationToken);

                return(wasUpdated);
            }
Exemplo n.º 23
0
        private static void GitLogic()
        {
            var token = "0ed16dbfa7996251b394b8735ccdc9f12aa221ac";

            var client = new GitHubClient(new ProductHeaderValue("amit-test-app"));

            var tokenAuth = new Credentials(token);

            client.Credentials = tokenAuth;

            var owner = "amitaroralive";

            var reponame = "api-repo-2";

            var organizationLogin = "******";

            //var newRepo = new NewRepository(reponame)
            //{

            //    AutoInit = true // very helpful!

            //};

            var getRepo = client.Repository.Get(organizationLogin, reponame);

            getRepo.Wait();

            //var repository = client.Repository.Create(organizationLogin, newRepo);
            //repository.Wait();

            Console.WriteLine("Browse the repository at: " + getRepo.Result.HtmlUrl);

            client.Repository.Collaborator.Add(getRepo.Result.Id, "amitaroralive2");

            //2 - create a blob containing the contents of our README

            var newBlob = new NewBlob()
            {
                Content  = "#MY AWESOME REPO\rthis is some code\rI made it on: " + DateTime.Now.ToString(),
                Encoding = EncodingType.Utf8
            };

            var createdBlob = client.Git.Blob.Create(getRepo.Result.Id, newBlob);

            createdBlob.Wait();


            // 3 - create a tree which represents just the README file
            var newTree = new NewTree();

            newTree.Tree.Add(new NewTreeItem()
            {
                Path = "test/README.md",
                Mode = Octokit.FileMode.File,
                Sha  = createdBlob.Result.Sha,
                Type = TreeType.Blob
            });



            var createdTree = client.Git.Tree.Create(getRepo.Result.Id, newTree);

            createdTree.Wait();


            // 4 - this commit should build on the current master branch
            var master = client.Git.Reference.Get(getRepo.Result.Id, "heads/master");

            master.Wait();
            var newCommit = new NewCommit(
                "Hello World!",
                createdTree.Result.Sha,
                new[] { master.Result.Object.Sha })
            {
                Author = new Committer("ram", "*****@*****.**", DateTime.UtcNow)
            };



            var createdCommit = client.Git.Commit.Create(getRepo.Result.Id, newCommit);

            createdCommit.Wait();

            // 5 - create a reference for the master branch

            var updateReference = new ReferenceUpdate(createdCommit.Result.Sha);

            var updatedReference = client.Git.Reference.Update(getRepo.Result.Id, "heads/master", updateReference);

            updatedReference.Wait();

            Console.Read();
        }
            public void PostsToCorrectUrlWithRepositoryId()
            {
                var referenceUpdate = new ReferenceUpdate("sha");
                var gitHubClient = Substitute.For<IGitHubClient>();
                var client = new ObservableReferencesClient(gitHubClient);

                client.Update(1, "heads/develop", referenceUpdate);

                gitHubClient.Received().Git.Reference.Update(1, "heads/develop", referenceUpdate);
            }
        /// <summary>
        /// Updates a reference for a given repository by reference name
        /// </summary>
        /// <remarks>
        /// http://developer.github.com/v3/git/refs/#update-a-reference
        /// </remarks>
        /// <param name="repositoryId">The ID of the repository</param>
        /// <param name="reference">The name of the reference</param>
        /// <param name="referenceUpdate">The updated reference data</param>
        /// <returns></returns>
        public IObservable<Reference> Update(int repositoryId, string reference, ReferenceUpdate referenceUpdate)
        {
            Ensure.ArgumentNotNullOrEmptyString(reference, "reference");
            Ensure.ArgumentNotNull(referenceUpdate, "update");

            return _reference.Update(repositoryId, reference, referenceUpdate).ToObservable();
        }
Exemplo n.º 26
0
        /// <summary>
        /// Uploads results to GitHub/Azure Table Storage
        /// </summary>
        /// <param name="scorecards">List of Scorecard instances to be uploaded</param>
        /// <param name="githubClient">An authenticated Octokit.GitHubClient instance</param>
        /// <param name="storageAccountKey">Key to the rollout scorecards storage account</param>
        /// <param name="githubConfig">GitHubConfig object representing config</param>
        public async static Task UploadResultsAsync(List <Scorecard> scorecards, GitHubClient githubClient, string storageAccountKey, GithubConfig githubConfig, bool skipPr = false)
        {
            // We batch the scorecards by date so they can be sorted into markdown files properly
            IEnumerable <ScorecardBatch> scorecardBatches = scorecards
                                                            .GroupBy(s => s.Date).Select(g => new ScorecardBatch {
                Date = g.Key, Scorecards = g.ToList()
            });

            const string TargetBranch = "main";

            if (!skipPr)
            {
                Reference targetBranch = await githubClient.Git.Reference
                                         .Get(githubConfig.ScorecardsGithubOrg, githubConfig.ScorecardsGithubRepo, "heads/" + TargetBranch);

                string    newBranchName = $"{DateTime.Today:yyyy-MM-dd}-Scorecard-Update";
                string    newBranchRef  = $"heads/{newBranchName}";
                Reference newBranch;

                // If this succeeds than the branch exists and we should update it directly
                try
                {
                    newBranch = await githubClient.Git.Reference.Get(githubConfig.ScorecardsGithubOrg,
                                                                     githubConfig.ScorecardsGithubRepo, newBranchRef);
                }
                // If not, we've got to create the new branch
                catch (NotFoundException)
                {
                    newBranch = await githubClient.Git.Reference.CreateBranch(githubConfig.ScorecardsGithubOrg,
                                                                              githubConfig.ScorecardsGithubRepo, newBranchName, targetBranch);
                }

                TreeResponse currentTree = await githubClient.Git.Tree.Get(githubConfig.ScorecardsGithubOrg,
                                                                           githubConfig.ScorecardsGithubRepo, newBranchRef);

                NewTree newTree = new NewTree
                {
                    BaseTree = currentTree.Sha,
                };

                // We loop over the batches and generate a markdown file for each rollout date
                foreach (ScorecardBatch scorecardBatch in scorecardBatches)
                {
                    List <RepoMarkdown> repoMarkdowns = scorecardBatch.Scorecards.Select(s => CreateRepoMarkdown(s)).ToList();

                    string scorecardBatchMarkdown = $"# {scorecardBatch.Date.Date:dd MMMM yyyy} Rollout Summaries\n\n" +
                                                    $"{string.Join('\n', repoMarkdowns.Select(md => md.Summary))}\n" +
                                                    $"# Itemized Scorecard\n\n" +
                                                    $"{string.Join('\n', repoMarkdowns.Select(md => md.Breakdown))}";

                    string scorecardBatchFilePath =
                        $"{githubConfig.ScorecardsDirectoryPath}Scorecard_{scorecardBatch.Date.Date:yyyy-MM-dd}.md";

                    NewTreeItem markdownBlob = new NewTreeItem
                    {
                        Path    = scorecardBatchFilePath,
                        Mode    = _gitFileBlobMode,
                        Type    = TreeType.Blob,
                        Content = scorecardBatchMarkdown,
                    };
                    newTree.Tree.Add(markdownBlob);
                }

                TreeResponse treeResponse = await githubClient.Git.Tree.Create(githubConfig.ScorecardsGithubOrg, githubConfig.ScorecardsGithubRepo, newTree);

                // Commit the new response to the new branch
                NewCommit newCommit = new NewCommit("Add scorecards for " +
                                                    string.Join(", ", scorecardBatches.Select(s => s.Date.Date.ToString("yyyy-MM-dd"))),
                                                    treeResponse.Sha,
                                                    newBranch.Object.Sha);
                Commit commit = await githubClient.Git.Commit
                                .Create(githubConfig.ScorecardsGithubOrg, githubConfig.ScorecardsGithubRepo, newCommit);

                ReferenceUpdate update     = new ReferenceUpdate(commit.Sha);
                Reference       updatedRef = await githubClient.Git.Reference.Update(githubConfig.ScorecardsGithubOrg,
                                                                                     githubConfig.ScorecardsGithubRepo, newBranchRef, update);

                PullRequestRequest prRequest = new PullRequestRequest
                {
                    Base  = TargetBranch,
                    Head  = newBranchName,
                    State = ItemStateFilter.Open,
                };
                // If an open PR exists already, we shouldn't try to create a new one
                List <PullRequest> prs =
                    (await githubClient.PullRequest.GetAllForRepository(githubConfig.ScorecardsGithubOrg, githubConfig.ScorecardsGithubRepo)).ToList();
                if (!prs.Any(pr => pr.Head.Ref == newBranchName))
                {
                    NewPullRequest newPullRequest = new NewPullRequest(newCommit.Message, newBranchName, TargetBranch);
                    await githubClient.PullRequest.Create(githubConfig.ScorecardsGithubOrg, githubConfig.ScorecardsGithubRepo, newPullRequest);
                }
            }

            // Upload the results to Azure Table Storage (will overwrite previous entries with new data if necessary)
            CloudTable table = Utilities.GetScorecardsCloudTable(storageAccountKey);

            foreach (Scorecard scorecard in scorecards)
            {
                ScorecardEntity scorecardEntity = new ScorecardEntity(scorecard.Date, scorecard.Repo.Repo)
                {
                    TotalScore           = scorecard.TotalScore,
                    TimeToRolloutSeconds = scorecard.TimeToRollout.TotalSeconds,
                    CriticalIssues       = scorecard.CriticalIssues,
                    Hotfixes             = scorecard.Hotfixes,
                    Rollbacks            = scorecard.Rollbacks,
                    DowntimeSeconds      = scorecard.Downtime.TotalSeconds,
                    Failure             = scorecard.Failure,
                    TimeToRolloutScore  = scorecard.TimeToRolloutScore,
                    CriticalIssuesScore = scorecard.CriticalIssueScore,
                    HotfixScore         = scorecard.HotfixScore,
                    RollbackScore       = scorecard.RollbackScore,
                    DowntimeScore       = scorecard.DowntimeScore,
                };
                await table.ExecuteAsync(TableOperation.InsertOrReplace(scorecardEntity));
            }
        }