Skip to content

Commit

Permalink
check if repo is empty, create readme if it is (microsoft#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
kostapetan authored Apr 5, 2024
1 parent b6f19e7 commit 00dffe9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions samples/gh-flow/src/Microsoft.AI.DevTeam/Services/GithubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public async Task CreateBranch(string org, string repo, string branch)
try
{
var ghRepo = await _ghClient.Repository.Get(org, repo);
if (ghRepo.Size == 0)
{
// Create a new file and commit it to the repository
var createChangeSet = await _ghClient.Repository.Content.CreateFile(
org,
repo,
"README.md",
new CreateFileRequest("Initial commit", "# Readme")
);
}

await _ghClient.Git.Reference.CreateBranch(org, repo, branch, ghRepo.DefaultBranch);
}
catch (Exception ex)
Expand Down

0 comments on commit 00dffe9

Please sign in to comment.