Skip to content

Commit d8ade9c

Browse files
committed
Commit 记录的跳转
1 parent 5faa1a7 commit d8ade9c

6 files changed

Lines changed: 57 additions & 21 deletions

File tree

Coding_iOS/Controllers/CommitFilesViewController.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111

1212
@interface CommitFilesViewController : BaseViewController
1313
@property (strong, nonatomic) NSString *ownerGK, *projectName, *commitId;
14-
@property (strong, nonatomic) Project *curProject;
14+
@property (strong, nonatomic) Project *curProject;//非必需
15+
+ (CommitFilesViewController *)vcWithPath:(NSString *)path;
16+
- (void)refresh;
1517
@end

Coding_iOS/Controllers/CommitFilesViewController.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ @interface CommitFilesViewController ()<UITableViewDataSource, UITableViewDelega
3636
@end
3737

3838
@implementation CommitFilesViewController
39+
40+
+ (CommitFilesViewController *)vcWithPath:(NSString *)path{
41+
42+
NSArray *pathComponents = [path componentsSeparatedByString:@"/"];
43+
if (pathComponents.count != 8) {
44+
return nil;
45+
}
46+
CommitFilesViewController *vc = [CommitFilesViewController new];
47+
vc.ownerGK = pathComponents[2];
48+
vc.projectName = pathComponents[4];
49+
vc.commitId = pathComponents[7];
50+
return vc;
51+
}
52+
3953
- (void)viewDidLoad{
4054
[super viewDidLoad];
4155

Coding_iOS/Controllers/MRPRDetailViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
@interface MRPRDetailViewController : BaseViewController
1414
@property (strong, nonatomic) MRPR *curMRPR;
15-
@property (strong, nonatomic) Project *curProject;
15+
@property (strong, nonatomic) Project *curProject;//非必需
1616
+ (MRPRDetailViewController *)vcWithPath:(NSString *)path;
1717
- (void)refresh;
1818
@end

Coding_iOS/Controllers/MRPRDetailViewController.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ + (MRPRDetailViewController *)vcWithPath:(NSString *)path{
5454
vc.curMRPR = [MRPR new];
5555
vc.curMRPR.path = path;
5656
vc.curMRPR.iid = [NSNumber numberWithInteger:[(NSString *)pathComponents.lastObject integerValue]];
57-
58-
vc.curProject = [Project new];
59-
vc.curProject.owner_user_name = vc.curMRPR.des_owner_name;
60-
vc.curProject.name = vc.curMRPR.des_project_name;
61-
57+
6258
return vc;
6359
}
6460
- (void)viewDidLoad{

Coding_iOS/Controllers/ProjectViewController.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#import "ProjectCommitsViewController.h"
3434
#import "MRPRDetailViewController.h"
3535
#import "NProjectViewController.h"
36+
#import "CommitFilesViewController.h"
3637

3738
@interface ProjectViewController ()
3839

@@ -438,11 +439,17 @@ - (void)goToVCWithItem:(HtmlMediaItem *)clickedItem activity:(ProjectActivity *)
438439
}else if ([target_type isEqualToString:@"CommitLineNote"]){
439440
request_path = proAct.line_note.noteable_url;
440441
}
441-
MRPRDetailViewController *vc = [MRPRDetailViewController vcWithPath:request_path];
442+
443+
UIViewController *vc;
444+
if ([proAct.line_note.noteable_type isEqualToString:@"Commit"]) {
445+
vc = [CommitFilesViewController vcWithPath:request_path];
446+
}else{
447+
vc = [MRPRDetailViewController vcWithPath:request_path];
448+
}
442449
if (vc) {
443450
[self.navigationController pushViewController:vc animated:YES];
444451
}else{
445-
[self showHudTipStr:@"RequestBean 没找到~"];
452+
[self showHudTipStr:@"不知道这是个什么东西o(╯□╰)o~"];
446453
}
447454
}else{
448455
if ([target_type isEqualToString:@"Project"]){//这是什么鬼。。遗留的 type 吧

Coding_iOS/Controllers/RootControllers/BaseViewController.m

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#import "ProjectCommitsViewController.h"
2828
#import "MRPRDetailViewController.h"
29+
#import "CommitFilesViewController.h"
2930

3031
#import "UnReadManager.h"
3132

@@ -155,7 +156,7 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
155156
NSString *ppRegexStr = @"/u/([^/]+)/pp/([0-9]+)$";
156157
NSString *topicRegexStr = @"/u/([^/]+)/p/([^/]+)/topic/(\\d+)";
157158
NSString *taskRegexStr = @"/u/([^/]+)/p/([^/]+)/task/(\\d+)";
158-
NSString *mergeRegexStr = @"/u/([^/]+)/p/([^/]+)/git/(merge|pull)/(\\d+)";
159+
NSString *gitMRPRCommitRegexStr = @"/u/([^/]+)/p/([^/]+)/git/(merge|pull|commit)/(\\d+)";
159160
NSString *conversionRegexStr = @"/user/messages/history/([^/]+)$";
160161
NSString *projectRegexStr = @"/u/([^/]+)/p/([^/]+)";
161162
NSArray *matchedCaptures = nil;
@@ -178,20 +179,36 @@ + (UIViewController *)analyseVCFromLinkStr:(NSString *)linkStr analyseMethod:(An
178179
vc.curTweet = [Tweet tweetWithGlobalKey:user_global_key andPPID:pp_id];
179180
analyseVC = vc;
180181
}
181-
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:mergeRegexStr]).count > 0){
182+
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:gitMRPRCommitRegexStr]).count > 0){
182183
//MR
183184
NSString *path = [linkStr stringByReplacingOccurrencesOfString:@"https://coding.net" withString:@""];
184-
185-
if ([presentingVC isKindOfClass:[MRPRDetailViewController class]]) {
186-
MRPRDetailViewController *vc = (MRPRDetailViewController *)presentingVC;
187-
if ([vc.curMRPR.path isEqualToString:path]) {
188-
[vc refresh];
189-
analyseVCIsNew = NO;
190-
analyseVC = vc;
185+
186+
if ([matchedCaptures[3] isEqualToString:@"commit"]) {
187+
if ([presentingVC isKindOfClass:[CommitFilesViewController class]]) {
188+
CommitFilesViewController *vc = (CommitFilesViewController *)presentingVC;
189+
if ([vc.commitId isEqualToString:matchedCaptures[3]] &&
190+
[vc.projectName isEqualToString:matchedCaptures[2]] &&
191+
[vc.ownerGK isEqualToString:matchedCaptures[1]]) {
192+
[vc refresh];
193+
analyseVCIsNew = NO;
194+
analyseVC = vc;
195+
}
196+
}
197+
if (!analyseVC) {
198+
analyseVC = [CommitFilesViewController vcWithPath:path];
199+
}
200+
}else{
201+
if ([presentingVC isKindOfClass:[MRPRDetailViewController class]]) {
202+
MRPRDetailViewController *vc = (MRPRDetailViewController *)presentingVC;
203+
if ([vc.curMRPR.path isEqualToString:path]) {
204+
[vc refresh];
205+
analyseVCIsNew = NO;
206+
analyseVC = vc;
207+
}
208+
}
209+
if (!analyseVC) {
210+
analyseVC = [MRPRDetailViewController vcWithPath:path];
191211
}
192-
}
193-
if (!analyseVC) {
194-
analyseVC = [MRPRDetailViewController vcWithPath:path];
195212
}
196213
}else if ((matchedCaptures = [linkStr captureComponentsMatchedByRegex:topicRegexStr]).count > 0){
197214
//讨论

0 commit comments

Comments
 (0)