@@ -220,24 +220,33 @@ - (void)gitPullBlock:(void(^)(BOOL result, NSString *tipStr))handleBlock progres
220
220
}else {
221
221
GTConfiguration *configuration = [repo configurationWithError: nil ];
222
222
GTRemote *remote = configuration.remotes .firstObject ;
223
- BOOL success = NO ;
224
- GTBranch *masterBranch = [repo lookUpBranchWithName: @" master" type: GTBranchTypeLocal success: &success error: nil ];
225
- if (!remote || !masterBranch) {
223
+ if (!remote) {
226
224
handleBlock (NO , @" 仓库信息不完整" );
227
225
}else {
228
226
__weak typeof (self) weakSelf = self;
229
227
dispatch_async (dispatch_get_global_queue (DISPATCH_QUEUE_PRIORITY_DEFAULT, 0 ), ^{
230
- NSMutableDictionary *options = @{GTRepositoryRemoteOptionsDownloadTags: @(GTRemoteDownloadTagsAuto)}.mutableCopy ;
231
- if (weakSelf.is_public && !weakSelf.is_public .boolValue ) {// 私有项目
232
- options[GTRepositoryRemoteOptionsCredentialProvider] = [weakSelf.class p_credentialProvider ];
233
- }
234
228
NSError *error = nil ;
235
- BOOL result = [repo pullBranch: masterBranch fromRemote: remote withOptions: options error: &error progress: progressBlock];
236
- dispatch_async (dispatch_get_main_queue (), ^{
237
- if (handleBlock) {
238
- handleBlock (result, error.localizedDescription );
229
+ NSArray <GTBranch *> *branchList = [repo localBranchesWithError: &error];
230
+ if (branchList.count > 0 ) {
231
+ GTBranch *curBranch = branchList.firstObject ;
232
+ NSMutableDictionary *options = @{GTRepositoryRemoteOptionsDownloadTags: @(GTRemoteDownloadTagsAuto)}.mutableCopy ;
233
+ if (weakSelf.is_public && !weakSelf.is_public .boolValue ) {// 私有项目
234
+ options[GTRepositoryRemoteOptionsCredentialProvider] = [weakSelf.class p_credentialProvider ];
239
235
}
240
- });
236
+ NSError *error = nil ;
237
+ BOOL result = [repo pullBranch: curBranch fromRemote: remote withOptions: options error: &error progress: progressBlock];
238
+ dispatch_async (dispatch_get_main_queue (), ^{
239
+ if (handleBlock) {
240
+ handleBlock (result, error.localizedDescription );
241
+ }
242
+ });
243
+ }else {
244
+ dispatch_async (dispatch_get_main_queue (), ^{
245
+ if (handleBlock) {
246
+ handleBlock (NO , @" 本地分支为空,请删除后,重新 clone 代码" );
247
+ }
248
+ });
249
+ }
241
250
});
242
251
}
243
252
}
0 commit comments