Skip to content

Commit c991f61

Browse files
akordowskigep13
authored andcommitted
(GH-110) Update code due API changes
1 parent fa0142a commit c991f61

File tree

7 files changed

+39
-30
lines changed

7 files changed

+39
-30
lines changed

Source/GitReleaseManager.Cli/Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ private static async Task<Release> CreateReleaseFromMilestone(GitHubClient githu
187187

188188
var releaseUpdate = CreateNewRelease(milestone, result, prerelease, targetCommitish);
189189

190-
var release = await github.Release.Create(owner, repository, releaseUpdate);
190+
var release = await github.Repository.Release.Create(owner, repository, releaseUpdate);
191191

192192
await AddAssets(github, assets, release);
193193

@@ -205,7 +205,7 @@ private static async Task<Release> CreateReleaseFromInputFile(GitHubClient githu
205205

206206
var releaseUpdate = CreateNewRelease(name, inputFileContents, prerelease, targetCommitish);
207207

208-
var release = await github.Release.Create(owner, repository, releaseUpdate);
208+
var release = await github.Repository.Release.Create(owner, repository, releaseUpdate);
209209

210210
await AddAssets(github, assets, release);
211211

@@ -214,7 +214,7 @@ private static async Task<Release> CreateReleaseFromInputFile(GitHubClient githu
214214

215215
private static async Task AddAssets(GitHubClient github, string owner, string repository, string tagName, IList<string> assets)
216216
{
217-
var releases = await github.Release.GetAll(owner, repository);
217+
var releases = await github.Repository.Release.GetAll(owner, repository);
218218

219219
var release = releases.FirstOrDefault(r => r.TagName == tagName);
220220

@@ -239,7 +239,7 @@ private static async Task<string> ExportReleases(GitHubClient github, string own
239239
private static async Task CloseMilestone(GitHubClient github, string owner, string repository, string milestoneTitle)
240240
{
241241
var milestoneClient = github.Issue.Milestone;
242-
var openMilestones = await milestoneClient.GetAllForRepository(owner, repository, new MilestoneRequest { State = ItemState.Open });
242+
var openMilestones = await milestoneClient.GetAllForRepository(owner, repository, new MilestoneRequest { State = ItemStateFilter.Open });
243243
var milestone = openMilestones.FirstOrDefault(m => m.Title == milestoneTitle);
244244

245245
if (milestone == null)
@@ -252,7 +252,7 @@ private static async Task CloseMilestone(GitHubClient github, string owner, stri
252252

253253
private static async Task PublishRelease(GitHubClient github, string owner, string repository, string tagName)
254254
{
255-
var releases = await github.Release.GetAll(owner, repository);
255+
var releases = await github.Repository.Release.GetAll(owner, repository);
256256
var release = releases.FirstOrDefault(r => r.TagName == tagName);
257257

258258
if (release == null)
@@ -262,7 +262,7 @@ private static async Task PublishRelease(GitHubClient github, string owner, stri
262262

263263
var releaseUpdate = new ReleaseUpdate { TagName = tagName, Draft = false };
264264

265-
await github.Release.Edit(owner, repository, release.Id, releaseUpdate);
265+
await github.Repository.Release.Edit(owner, repository, release.Id, releaseUpdate);
266266
}
267267

268268
private static async Task AddAssets(GitHubClient github, IList<string> assets, Release release)
@@ -283,7 +283,7 @@ private static async Task AddAssets(GitHubClient github, IList<string> assets, R
283283
RawData = File.Open(asset, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
284284
};
285285

286-
await github.Release.UploadAsset(release, upload);
286+
await github.Repository.Release.UploadAsset(release, upload);
287287

288288
// Make sure to tidy up the stream that was created above
289289
upload.RawData.Dispose();

Source/GitReleaseManager.Tests/ReleaseNotesBuilderTests.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,28 +151,35 @@ private static void AcceptTest(int commits, Config config, params Issue[] issues
151151

152152
private static Milestone CreateMilestone(string version)
153153
{
154-
return new Milestone(new Uri("https://github.com/gep13/FakeRepository/issues?q=milestone%3A" + version), 0, ItemState.Open, version, String.Empty, null, 0, 0, DateTimeOffset.Now, null, null);
154+
return new Milestone(null, "https://github.com/gep13/FakeRepository/issues?q=milestone%3A" + version, 0, ItemState.Open, version, String.Empty, null, 0, 0, DateTimeOffset.Now, null, null, null);
155155
}
156156

157157
private static Issue CreateIssue(int number, params string[] labels)
158158
{
159+
var user = new User(null, null, null, 0, null, DateTimeOffset.Now, DateTimeOffset.Now, 0, null, 0, 0, null, null, 0, 0, null, "gep13", "gep31", 0, null, 0, 0, 0, null, null, false, null, null);
160+
159161
return new Issue(
160162
null,
161-
new Uri("http://example.com/" + number),
163+
"http://example.com/" + number,
162164
null,
163165
null,
164166
number,
165167
ItemState.Open,
166168
"Issue " + number,
167169
"Some issue",
168170
null,
169-
labels.Select(x => new Label (null, x, null)).ToArray(),
171+
null,
172+
labels.Select(x => new Label(null, x, null)).ToArray(),
173+
user,
170174
null,
171175
null,
172176
0,
173177
null,
174178
null,
175179
DateTimeOffset.Now,
180+
null,
181+
0,
182+
false,
176183
null);
177184
}
178185
}

Source/GitReleaseManager.Tests/ReleaseNotesExporterTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private static Release CreateRelease(int id, DateTime createdDateTime, string mi
8686
stringBuilder.AppendLine();
8787
stringBuilder.AppendLine("- [__#3__](http://example.com/3) Issue 3");
8888

89-
return new Release(null, null, null, null, id, milestone, "master", milestone, stringBuilder.ToString(), false, false, createdDateTime, null);
89+
return new Release(null, null, null, null, id, milestone, "master", milestone, stringBuilder.ToString(), false, false, createdDateTime, null, null, null, null, null);
9090
}
9191
}
9292
}

Source/GitReleaseManager/Configuration/ConfigSerializer.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ public static class ConfigSerializer
1515
{
1616
public static Config Read(TextReader reader)
1717
{
18-
var deserializer = new Deserializer(null, new HyphenatedNamingConvention());
18+
var deserializerBuilder = new DeserializerBuilder().WithNamingConvention(new HyphenatedNamingConvention());
19+
var deserializer = deserializerBuilder.Build();
1920
var deserialize = deserializer.Deserialize<Config>(reader);
20-
21+
2122
if (deserialize == null)
2223
{
2324
return new Config();
@@ -28,7 +29,8 @@ public static Config Read(TextReader reader)
2829

2930
public static void Write(Config config, TextWriter writer)
3031
{
31-
var serializer = new Serializer(SerializationOptions.None, new HyphenatedNamingConvention());
32+
var serializerBuilder = new SerializerBuilder().WithNamingConvention(new HyphenatedNamingConvention());
33+
var serializer = serializerBuilder.Build();
3234
serializer.Serialize(writer, config);
3335
}
3436

Source/GitReleaseManager/DefaultGitHubClient.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public async Task<int> GetNumberOfCommitsBetween(Milestone previousMilestone, Mi
3131
{
3232
if (previousMilestone == null)
3333
{
34-
var gitHubClientRepositoryCommitsCompare = await this.gitHubClient.Repository.Commits.Compare(this.user, this.repository, "master", currentMilestone.Title);
34+
var gitHubClientRepositoryCommitsCompare = await this.gitHubClient.Repository.Commit.Compare(this.user, this.repository, "master", currentMilestone.Title);
3535
return gitHubClientRepositoryCommitsCompare.AheadBy;
3636
}
3737

38-
var compareResult = await this.gitHubClient.Repository.Commits.Compare(this.user, this.repository, previousMilestone.Title, "master");
38+
var compareResult = await this.gitHubClient.Repository.Commit.Compare(this.user, this.repository, previousMilestone.Title, "master");
3939
return compareResult.AheadBy;
4040
}
4141
catch (NotFoundException)
@@ -54,13 +54,13 @@ public async Task<List<Issue>> GetIssues(Milestone targetMilestone)
5454

5555
public async Task<List<Release>> GetReleases()
5656
{
57-
var allReleases = await this.gitHubClient.Release.GetAll(this.user, this.repository);
57+
var allReleases = await this.gitHubClient.Repository.Release.GetAll(this.user, this.repository);
5858
return allReleases.OrderByDescending(r => r.CreatedAt).ToList();
5959
}
6060

6161
public async Task<Release> GetSpecificRelease(string tagName)
6262
{
63-
var allReleases = await this.gitHubClient.Release.GetAll(this.user, this.repository);
63+
var allReleases = await this.gitHubClient.Repository.Release.GetAll(this.user, this.repository);
6464
return allReleases.FirstOrDefault(r => r.TagName == tagName);
6565
}
6666

@@ -71,17 +71,17 @@ public ReadOnlyCollection<Milestone> GetMilestones()
7171
this.user,
7272
this.repository,
7373
new MilestoneRequest
74-
{
75-
State = ItemState.Closed
76-
}).Result;
74+
{
75+
State = ItemStateFilter.Closed
76+
}).Result;
7777

7878
var open = milestonesClient.GetAllForRepository(
7979
this.user,
8080
this.repository,
8181
new MilestoneRequest
82-
{
83-
State = ItemState.Open
84-
}).Result;
82+
{
83+
State = ItemStateFilter.Open
84+
}).Result;
8585

8686
return new ReadOnlyCollection<Milestone>(closed.Concat(open).ToList());
8787
}

Source/GitReleaseManager/OctokitExtensions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ public static async Task<IEnumerable<Issue>> AllIssuesForMilestone(this GitHubCl
3030
var closedIssueRequest = new RepositoryIssueRequest
3131
{
3232
Milestone = milestone.Number.ToString(CultureInfo.InvariantCulture),
33-
State = ItemState.Closed
33+
State = ItemStateFilter.Closed
3434
};
3535
var openIssueRequest = new RepositoryIssueRequest
3636
{
3737
Milestone = milestone.Number.ToString(CultureInfo.InvariantCulture),
38-
State = ItemState.Open
38+
State = ItemStateFilter.Open
3939
};
40-
var parts = milestone.Url.AbsolutePath.Split('/');
40+
var parts = milestone.Url.Split('/');
4141
var user = parts[2];
4242
var repository = parts[3];
4343
var closedIssues = await gitHubClient.Issue.GetAllForRepository(user, repository, closedIssueRequest);
@@ -52,7 +52,7 @@ public static Uri HtmlUrl(this Milestone milestone)
5252
throw new ArgumentNullException("milestone");
5353
}
5454

55-
var parts = milestone.Url.AbsolutePath.Split('/');
55+
var parts = milestone.Url.Split('/');
5656
var user = parts[2];
5757
var repository = parts[3];
5858

Source/GitReleaseManager/ReleaseNotesBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ public async Task<string> BuildReleaseNotes()
5454
var commitsLink = this.GetCommitsLink(previousMilestone);
5555
var commitsText = string.Format(numberOfCommits == 1 ? "{0} commit" : "{0} commits", numberOfCommits);
5656

57-
stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) which resulted in [{2}]({3}) being closed.", commitsText, commitsLink, issuesText, this.targetMilestone.HtmlUrl());
57+
stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) which resulted in [{2}]({3}) being closed.", commitsText, commitsLink, issuesText, this.targetMilestone.HtmlUrl);
5858
}
5959
else
6060
{
61-
stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) closed.", issuesText, this.targetMilestone.HtmlUrl());
61+
stringBuilder.AppendFormat(@"As part of this release we had [{0}]({1}) closed.", issuesText, this.targetMilestone.HtmlUrl);
6262
}
6363
}
6464
else if (numberOfCommits > 0)

0 commit comments

Comments
 (0)