breakout_parser 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ [ 0.0.20 ]
2
+
3
+ * parse "$REV$" in external repo links
4
+ (https://www.assembla.com/spaces/breakout/tickets/6496)
5
+
1
6
  [ 0.0.19 ]
2
7
 
3
8
  * skip redundant '/' in making relative urls absolute
@@ -2305,12 +2305,21 @@ process_svn_link(const char*target, int numbered_repo){
2305
2305
  process_link_tail(target,NULL,"revision:");
2306
2306
  }
2307
2307
 
2308
- int concat_custom_git_url(){
2309
- const char *c;
2308
+ int concat_custom_git_url(const char*rev){
2309
+ const char *c,*p,*t;
2310
2310
  if( git_url && (c = StringValuePtr(git_url)) ){
2311
2311
  size_t l = strlen(c);
2312
2312
  if( l>0 ){
2313
- concat2(c);
2313
+ if( p=strstr(c, "$REV$") ){
2314
+ concat(c, p-c);
2315
+ // concat revision number
2316
+ for(t=rev; *t && *t!=']' && *t!='|'; t++) concat_raw_char(*t);
2317
+ concat2(p+5);
2318
+ } else {
2319
+ concat2(c);
2320
+ // concat revision number
2321
+ for(t=rev; *t && *t!=']' && *t!='|'; t++) concat_raw_char(*t);
2322
+ }
2314
2323
  return 1;
2315
2324
  }
2316
2325
  }
@@ -2321,7 +2330,7 @@ process_git_link(const char*target, int numbered_repo){
2321
2330
  const char *c;
2322
2331
  // can use sprintf here.. but I think it's a way slower than raw concat
2323
2332
  concat("<a href=\"",9);
2324
- if( !concat_custom_git_url() ){
2333
+ if( !concat_custom_git_url(target) ){
2325
2334
  concat_site_url();
2326
2335
  concat("/code/",6);
2327
2336
  concat(space_name,space_name_len);
@@ -2333,8 +2342,8 @@ process_git_link(const char*target, int numbered_repo){
2333
2342
  } else {
2334
2343
  concat("/git/changesets/",16);
2335
2344
  }
2345
+ for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
2336
2346
  }
2337
- for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
2338
2347
  process_link_tail(target,NULL,"revision:");
2339
2348
  }
2340
2349
 
@@ -374,12 +374,21 @@ process_svn_link(const char*target, int numbered_repo){
374
374
  process_link_tail(target,NULL,"revision:");
375
375
  }
376
376
 
377
- int concat_custom_git_url(){
378
- const char *c;
377
+ int concat_custom_git_url(const char*rev){
378
+ const char *c,*p,*t;
379
379
  if( git_url && (c = StringValuePtr(git_url)) ){
380
380
  size_t l = strlen(c);
381
381
  if( l>0 ){
382
- concat2(c);
382
+ if( p=strstr(c, "$REV$") ){
383
+ concat(c, p-c);
384
+ // concat revision number
385
+ for(t=rev; *t && *t!=']' && *t!='|'; t++) concat_raw_char(*t);
386
+ concat2(p+5);
387
+ } else {
388
+ concat2(c);
389
+ // concat revision number
390
+ for(t=rev; *t && *t!=']' && *t!='|'; t++) concat_raw_char(*t);
391
+ }
383
392
  return 1;
384
393
  }
385
394
  }
@@ -390,7 +399,7 @@ process_git_link(const char*target, int numbered_repo){
390
399
  const char *c;
391
400
  // can use sprintf here.. but I think it's a way slower than raw concat
392
401
  concat("<a href=\"",9);
393
- if( !concat_custom_git_url() ){
402
+ if( !concat_custom_git_url(target) ){
394
403
  concat_site_url();
395
404
  concat("/code/",6);
396
405
  concat(space_name,space_name_len);
@@ -402,8 +411,8 @@ process_git_link(const char*target, int numbered_repo){
402
411
  } else {
403
412
  concat("/git/changesets/",16);
404
413
  }
414
+ for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
405
415
  }
406
- for(c=target; *c && *c!=']' && *c!='|'; c++) concat_raw_char(*c);
407
416
  process_link_tail(target,NULL,"revision:");
408
417
  }
409
418
 
data/spec/parser_spec.rb CHANGED
@@ -896,6 +896,39 @@ describe 'BreakoutParser' do
896
896
  v.sub('/code/test_space/git/changesets/',git_url)
897
897
  end
898
898
 
899
+ it "parses [[#{k}]] with custom git_url (String) + $REV$" do
900
+ git_url = "http://www.ru/$REV$/show"
901
+ rev = k.split(':').last.tr(']','')
902
+ parse("[[#{k}]]", :git_url => git_url).should ==
903
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
904
+
905
+ git_url = "http://www.ru/$REV$"
906
+ parse("[[#{k}]]", :git_url => git_url).should ==
907
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
908
+
909
+ git_url = "$REV$"
910
+ parse("[[#{k}]]", :git_url => git_url).should ==
911
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
912
+ end
913
+
914
+ it "parses [[#{k}]] with custom git_url (ObjProxy) + $REV$" do
915
+ rev = k.split(':').last.tr(']','')
916
+ @asdfg = 'http://mmm.us/$REV$/show'
917
+ git_url = Breakout::ObjProxy.new do
918
+ @asdfg
919
+ end
920
+ parse("[[#{k}]]", :git_url => git_url).should ==
921
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
922
+
923
+ @asdfg = 'http://mmm.us/$REV$'
924
+ parse("[[#{k}]]", :git_url => git_url).should ==
925
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
926
+
927
+ @asdfg = '$REV$'
928
+ parse("[[#{k}]]", :git_url => git_url).should ==
929
+ v.sub('/code/test_space/git/changesets/',git_url).sub(rev,'').sub('$REV$',rev)
930
+ end
931
+
899
932
  it "parses [[#{k}]] with NULL git_url (ObjProxy)" do
900
933
  rev = k.split(':').last.tr(']','')
901
934
  git_url = Breakout::ObjProxy.new do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: breakout_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 57
4
+ hash: 55
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 19
10
- version: 0.0.19
9
+ - 20
10
+ version: 0.0.20
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrey "Zed" Zaikin