-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the required status code StatusCodes.CREATED for the createRele… #231
Changes from all commits
34439bf
5d41ad0
5700cda
7ba7629
16bfe55
dfe06d7
6caf3ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ class Release { | |
String getUploadUrlFor(String name, [String label]) => | ||
"${uploadUrl.substring(0, uploadUrl.indexOf('{'))}?name=$name${label != null ? ",$label" : ""}"; | ||
|
||
bool get hasErrors => errors?.isNotEmpty; | ||
bool get hasErrors => errors == null ? false : errors.isNotEmpty; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a feeling that returning null from hasErrors was causing a problem which is why I changed it to return false. I can't quite remember the circumstances. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've just checked and the method createRelease has the following line: if (release.hasErrors) { As such hasErrors should never be null. |
||
} | ||
|
||
/// Model class for a release asset. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -968,10 +968,23 @@ class RepositoriesService extends Service { | |
|
||
/// Fetches a single release by the release tag name. | ||
/// | ||
/// Throws a [ReleaseNotFound] exception if the release | ||
/// doesn't exist. | ||
/// | ||
/// API docs: https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name | ||
Future<Release> getReleaseByTagName(RepositorySlug slug, String tagName) => | ||
github.getJSON('/repos/${slug.fullName}/releases/tags/$tagName', | ||
convert: (i) => Release.fromJson(i)); | ||
Future<Release> getReleaseByTagName( | ||
RepositorySlug slug, String tagName) async { | ||
return github.getJSON( | ||
'/repos/${slug.fullName}/releases/tags/$tagName', | ||
convert: (i) => Release.fromJson(i), | ||
statusCode: StatusCodes.OK, | ||
fail: (http.Response response) { | ||
if (response.statusCode == 404) { | ||
throw ReleaseNotFound.fromTagName(github, tagName); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
/// Creates a Release based on the specified [createRelease]. | ||
/// | ||
|
@@ -986,10 +999,10 @@ class RepositoriesService extends Service { | |
ArgumentError.checkNotNull(slug); | ||
ArgumentError.checkNotNull(createRelease); | ||
final release = await github.postJSON<Map<String, dynamic>, Release>( | ||
'/repos/${slug.fullName}/releases', | ||
convert: (i) => Release.fromJson(i), | ||
body: GitHubJson.encode(createRelease.toJson()), | ||
); | ||
'/repos/${slug.fullName}/releases', | ||
convert: (i) => Release.fromJson(i), | ||
body: GitHubJson.encode(createRelease.toJson()), | ||
statusCode: StatusCodes.CREATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part looks ok to me. |
||
if (release.hasErrors) { | ||
final alreadyExistsErrorCode = release.errors.firstWhere( | ||
(error) => error['code'] == 'already_exists', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍