Skip to content

Commit

Permalink
Add Repository Fork Creation Support
Browse files Browse the repository at this point in the history
  • Loading branch information
azenla committed Aug 24, 2014
1 parent 0e5013e commit 0c61d9a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/src/common/organization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class TeamRepository extends Repository {
..name = input['name']
..id = input['id']
..fullName = input['full_name']
..fork = input['fork']
..isFork = input['fork']
..url = input['html_url']
..description = input['description']
..cloneUrls = new CloneUrls()
Expand Down
22 changes: 20 additions & 2 deletions lib/src/common/repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class Repository {
/**
* If the Repository is a fork
*/
bool fork;
@ApiName("fork")
bool isFork;

/**
* Url to the GitHub Repository Page
Expand Down Expand Up @@ -150,7 +151,7 @@ class Repository {
..name = input['name']
..id = input['id']
..fullName = input['full_name']
..fork = input['fork']
..isFork = input['fork']
..url = input['html_url']
..description = input['description']
..cloneUrls = new CloneUrls()
Expand Down Expand Up @@ -263,6 +264,11 @@ class Repository {
return copyOf(hooks.map((it) => Hook.fromJSON(github, fullName, it)));
});
}

Future<Repository> fork([CreateFork request]) {
if (request == null) request = new CreateFork();
return github.postJSON("/repos/${fullName}/forks", body: request.toJSON(), convert: Repository.fromJSON);
}

/**
* Gets the Repository Releases
Expand Down Expand Up @@ -535,4 +541,16 @@ class LanguageBreakdown {
});
return buffer.toString();
}
}

class CreateFork {
final String organization;

CreateFork([this.organization]);

String toJSON() {
var map = {};
putValue("organization", organization, map);
return JSON.encode(map);
}
}

0 comments on commit 0c61d9a

Please sign in to comment.