@@ -220,24 +220,33 @@ - (void)gitPullBlock:(void(^)(BOOL result, NSString *tipStr))handleBlock progres
220220 }else {
221221 GTConfiguration *configuration = [repo configurationWithError: nil ];
222222 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) {
226224 handleBlock (NO , @" 仓库信息不完整" );
227225 }else {
228226 __weak typeof (self) weakSelf = self;
229227 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- }
234228 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 ];
239235 }
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+ }
241250 });
242251 }
243252 }
0 commit comments