Skip to content

Commit 0c61d9a

Browse files
committed
Add Repository Fork Creation Support
1 parent 0e5013e commit 0c61d9a

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

lib/src/common/organization.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class TeamRepository extends Repository {
264264
..name = input['name']
265265
..id = input['id']
266266
..fullName = input['full_name']
267-
..fork = input['fork']
267+
..isFork = input['fork']
268268
..url = input['html_url']
269269
..description = input['description']
270270
..cloneUrls = new CloneUrls()

lib/src/common/repo.dart

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ class Repository {
3535
/**
3636
* If the Repository is a fork
3737
*/
38-
bool fork;
38+
@ApiName("fork")
39+
bool isFork;
3940

4041
/**
4142
* Url to the GitHub Repository Page
@@ -150,7 +151,7 @@ class Repository {
150151
..name = input['name']
151152
..id = input['id']
152153
..fullName = input['full_name']
153-
..fork = input['fork']
154+
..isFork = input['fork']
154155
..url = input['html_url']
155156
..description = input['description']
156157
..cloneUrls = new CloneUrls()
@@ -263,6 +264,11 @@ class Repository {
263264
return copyOf(hooks.map((it) => Hook.fromJSON(github, fullName, it)));
264265
});
265266
}
267+
268+
Future<Repository> fork([CreateFork request]) {
269+
if (request == null) request = new CreateFork();
270+
return github.postJSON("/repos/${fullName}/forks", body: request.toJSON(), convert: Repository.fromJSON);
271+
}
266272

267273
/**
268274
* Gets the Repository Releases
@@ -535,4 +541,16 @@ class LanguageBreakdown {
535541
});
536542
return buffer.toString();
537543
}
544+
}
545+
546+
class CreateFork {
547+
final String organization;
548+
549+
CreateFork([this.organization]);
550+
551+
String toJSON() {
552+
var map = {};
553+
putValue("organization", organization, map);
554+
return JSON.encode(map);
555+
}
538556
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy