Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Merge pull request #237 from leichunfeng/add-method-to-octclient+octr…
Browse files Browse the repository at this point in the history
…epository

Add `-fetchRepositoryReadme:reference:` method to `OCTClient+Repositorie...
  • Loading branch information
jspahrsummers committed Feb 11, 2015
2 parents 99f9887 + b69f7de commit 76c8f6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions OctoKit/OCTClient+Repositories.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@
// Returns a signal which will send zero or one OCTContent.
- (RACSignal *)fetchRepositoryReadme:(OCTRepository *)repository;

// Fetches the readme of a `repository` by the given `reference`.
//
// repository - The repository for which the readme should be fetched.
// reference - The name of the commit, branch or tag, may be `nil` in which
// case it defaults to the default repo branch.
//
// Returns a signal which will send zero or one OCTContent.
- (RACSignal *)fetchRepositoryReadme:(OCTRepository *)repository reference:(NSString *)reference;

// Fetches a specific repository owned by the given `owner` and named `name`.
//
// name - The name of the repository, must be a non-empty string.
Expand Down
8 changes: 7 additions & 1 deletion OctoKit/OCTClient+Repositories.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,18 @@ - (RACSignal *)fetchRelativePath:(NSString *)relativePath inRepository:(OCTRepos
}

- (RACSignal *)fetchRepositoryReadme:(OCTRepository *)repository {
return [self fetchRepositoryReadme:repository reference:nil];
}

- (RACSignal *)fetchRepositoryReadme:(OCTRepository *)repository reference:(NSString *)reference {
NSParameterAssert(repository != nil);
NSParameterAssert(repository.name.length > 0);
NSParameterAssert(repository.ownerLogin.length > 0);

NSString *path = [NSString stringWithFormat:@"repos/%@/%@/readme", repository.ownerLogin, repository.name];
NSMutableURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:nil notMatchingEtag:nil];
NSDictionary *parameters = (reference.length > 0 ? @{ @"ref": reference } : nil);

NSMutableURLRequest *request = [self requestWithMethod:@"GET" path:path parameters:parameters notMatchingEtag:nil];

return [[self enqueueRequest:request resultClass:OCTContent.class] oct_parsedResults];
}
Expand Down

0 comments on commit 76c8f6c

Please sign in to comment.