This repository has been archived by the owner on Dec 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 319
/
OCTClient+Git.h
127 lines (112 loc) · 5.37 KB
/
OCTClient+Git.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
// OCTClient+Git.h
// OctoKit
//
// Created by Justin Spahr-Summers on 2013-11-22.
// Copyright (c) 2013 GitHub. All rights reserved.
//
#import "OCTClient.h"
@class OCTRepository;
// The types of content encodings
// OCTContentEncodingUTF8 - utf-8
// OCTContentEncodingBase64 - base64
typedef NS_ENUM(NSInteger, OCTContentEncoding) {
OCTContentEncodingUTF8,
OCTContentEncodingBase64
};
@interface OCTClient (Git)
// Fetches the tree for the given reference.
//
// reference - The SHA, branch, reference, or tag to fetch. May be nil, in
// which case HEAD is fetched.
// repository - The repository from which the tree should be fetched. Cannot be
// nil.
// recursive - Should the tree be fetched recursively?
//
// Returns a signal which will send an OCTTree and complete or error.
- (RACSignal *)fetchTreeForReference:(NSString *)reference inRepository:(OCTRepository *)repository recursive:(BOOL)recursive;
// Creates a new tree.
//
// treeEntries - The `OCTTreeEntry` objects that should comprise the new tree.
// This array must not be nil.
// repository - The repository in which to create the tree. Cannot be nil.
// baseTreeSHA - The SHA of the tree upon which to base this new tree. This may
// be nil to create an orphaned tree.
//
// Returns a signal which will send the created OCTTree and complete, or error.
- (RACSignal *)createTreeWithEntries:(NSArray *)treeEntries inRepository:(OCTRepository *)repository basedOnTreeWithSHA:(NSString *)baseTreeSHA;
// Fetches the blob identified by the given SHA.
//
// blobSHA - The SHA of the blob to fetch. This must not be nil.
// repository - The repository from which the blob should be fetched. Cannot be
// nil.
//
// Returns a signal which will send an NSData then complete, or error.
- (RACSignal *)fetchBlob:(NSString *)blobSHA inRepository:(OCTRepository *)repository;
// Creates a blob using the given text content.
//
// string - The text for the new blob. This must not be nil.
// repository - The repository in which to create the blob. This must not be
// nil.
//
// Returns a signal which will send an NSString of the new blob's SHA then
// complete, or error.
- (RACSignal *)createBlobWithString:(NSString *)string inRepository:(OCTRepository *)repository;
// Creates a blob using the given text content and encoding
//
// string - The text for the new blob. This must not be nil.
// repository - The repository in which to create the blob. This must not be
// nil.
// encoding - The encoding of the text. utf-8 or base64, must not be nil.
//
// Returns a signal which will send an NSString of the new blob's SHA then
// complete, or error.
- (RACSignal *)createBlobWithString:(NSString *)string inRepository:(OCTRepository *)repository withEncoding:(OCTContentEncoding)encoding;
// Fetches the commit identified by the given SHA.
//
// commitSHA - The SHA of the commit to fetch. This must not be nil.
// repository - The repository from which the commit should be fetched. Cannot be
// nil.
//
// Returns a signal which will send an `OCTCommit` then complete, or error.
- (RACSignal *)fetchCommit:(NSString *)commitSHA inRepository:(OCTRepository *)repository;
// Creates a commit.
//
// message - The message of the new commit. This must not be nil.
// repository - The repository in which to create the commit. This must not be
// nil.
// treeSHA - The SHA of the tree for the new commit. This must not be nil.
// parentSHAs - An array of `NSString`s representing the SHAs of parent commits
// for the new commit. This can be empty to create a root commit,
// or have more than one object to create a merge commit. This
// array must not be nil.
//
// Returns a signal which will send the created `OCTCommit` then complete, or
// error.
- (RACSignal *)createCommitWithMessage:(NSString *)message inRepository:(OCTRepository *)repository pointingToTreeWithSHA:(NSString *)treeSHA parentCommitSHAs:(NSArray *)parentSHAs;
// Fetches all references in the given repository.
//
// repository - The repository in which to fetch the references. This must not be nil.
//
// Returns a signal which sends zero or more OCTRef objects then complete, or error.
- (RACSignal *)fetchAllReferencesInRepository:(OCTRepository *)repository;
// Fetches a git reference given its fully-qualified name.
//
// refName - The fully-qualified name of the ref to fetch (e.g.,
// `heads/master`). This must not be nil.
// repository - The repository in which to fetch the ref. This must not be nil.
//
// Returns a signal which will send an OCTRef then complete, or error.
- (RACSignal *)fetchReference:(NSString *)refName inRepository:(OCTRepository *)repository;
// Attempts to update a reference to point at a new SHA.
//
// refName - The fully-qualified name of the ref to update (e.g.,
// `heads/master`). This must not be nil.
// repository - The repository in which to update the ref. This must not be nil.
// newSHA - The new SHA for the ref. This must not be nil.
// force - Whether to force the ref to update, even if it cannot be
// fast-forwarded.
//
// Returns a signal which will send the updated OCTRef then complete, or error.
- (RACSignal *)updateReference:(NSString *)refName inRepository:(OCTRepository *)repository toSHA:(NSString *)newSHA force:(BOOL)force;
@end