editRelease method
Edits the given release with new fields.
tagName
: The name of the tag.targetCommitish
: Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master).name
: The name of the release.body
: Text describing the contents of the tag.draft
: true makes the release a draft, and false publishes the release.preRelease
: true to identify the release as a prerelease, false to identify the release as a full release.
Leave blank the fields you don't want to edit.
API docs: https://developer.github.com/v3/repos/releases/#edit-a-release
Implementation
Future<Release> editRelease(
RepositorySlug slug,
Release releaseToEdit, {
String? tagName,
String? targetCommitish,
String? name,
String? body,
bool? draft,
bool? preRelease,
}) async {
ArgumentError.checkNotNull(slug);
ArgumentError.checkNotNull(releaseToEdit);
return github.postJSON<Map<String, dynamic>, Release>(
'/repos/${slug.fullName}/releases/${releaseToEdit.id.toString()}',
body: GitHubJson.encode(createNonNullMap(<String, dynamic>{
'tag_name': tagName ?? releaseToEdit.tagName,
'target_commitish': targetCommitish ?? releaseToEdit.targetCommitish,
'name': name ?? releaseToEdit.name,
'body': body ?? releaseToEdit.body,
'draft': draft ?? releaseToEdit.isDraft,
'prerelease': preRelease ?? releaseToEdit.isPrerelease,
})),
statusCode: StatusCodes.OK,
convert: (i) => Release.fromJson(i),
);
}