Skip to content

Commit 7e93cc9

Browse files
committed
Update editRepository according to current documentation
Current Github docs specify most of the parameters as optional. This commit update the existing editRepository method to these specs. https://docs.github.com/en/rest/repos/repos#update-a-repository
1 parent 344c841 commit 7e93cc9

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

lib/src/common/repos_service.dart

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,34 @@ class RepositoriesService extends Service {
168168

169169
/// Edit a Repository.
170170
///
171-
/// API docs: https://developer.github.com/v3/repos/#edit
172-
Future<Repository> editRepository(RepositorySlug slug,
173-
{String? name,
174-
String? description,
175-
String? homepage,
176-
bool? private,
177-
bool? hasIssues,
178-
bool? hasWiki,
179-
bool? hasDownloads}) async {
171+
/// API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository
172+
Future<Repository> editRepository(
173+
RepositorySlug slug, {
174+
String? name,
175+
String? description,
176+
String? homepage,
177+
bool? private,
178+
bool? hasIssues,
179+
bool? hasWiki,
180+
bool? hasDownloads,
181+
String? defaultBranch,
182+
}) async {
180183
ArgumentError.checkNotNull(slug);
184+
181185
final data = createNonNullMap({
182-
'name': name!,
183-
'description': description!,
184-
'homepage': homepage!,
185-
'private': private!,
186-
'has_issues': hasIssues!,
187-
'has_wiki': hasWiki!,
188-
'has_downloads': hasDownloads!,
189-
'default_branch': 'defaultBranch'
186+
'name': name,
187+
'description': description,
188+
'homepage': homepage,
189+
'private': private,
190+
'has_issues': hasIssues,
191+
'has_wiki': hasWiki,
192+
'has_downloads': hasDownloads,
193+
'default_branch': defaultBranch,
190194
});
191-
return github.postJSON(
195+
return github.postJSON<Map<String, dynamic>, Repository>(
192196
'/repos/${slug.fullName}',
193197
body: GitHubJson.encode(data),
198+
convert: (i) => Repository.fromJson(i),
194199
statusCode: 200,
195200
);
196201
}

0 commit comments

Comments
 (0)