editReference method
Future<GitReference>
editReference(
- RepositorySlug slug,
- String ref,
- String? sha, {
- bool force = false,
Updates a reference in a repository.
API docs: https://developer.github.com/v3/git/refs/#update-a-reference
Implementation
Future<GitReference> editReference(
RepositorySlug slug,
String ref,
String? sha, {
bool force = false,
}) {
final body = GitHubJson.encode({'sha': sha, 'force': force});
// Somehow the reference updates PATCH request needs a valid content-length.
final headers = {'content-length': body.length.toString()};
return github
.request('PATCH', '/repos/${slug.fullName}/git/refs/$ref',
body: body, headers: headers)
.then((response) {
return GitReference.fromJson(
jsonDecode(response.body) as Map<String, dynamic>);
});
}