@@ -7,9 +7,11 @@ public class QueryTags : Command
7
7
{
8
8
public QueryTags ( string repo )
9
9
{
10
+ _boundary = $ "----- BOUNDARY OF TAGS { Guid . NewGuid ( ) } -----";
11
+
10
12
Context = repo ;
11
13
WorkingDirectory = repo ;
12
- Args = "tag -l --sort=-creatordate --format=\" $ %(refname)$% (objectname)$% (*objectname)\" " ;
14
+ Args = $ "tag -l --sort=-creatordate --format=\" { _boundary } %(refname)%00% (objectname)%00% (*objectname)%00%(contents:subject)%0a%0a%(contents:body )\" ";
13
15
}
14
16
15
17
public List < Models . Tag > Result ( )
@@ -19,38 +21,25 @@ public QueryTags(string repo)
19
21
if ( ! rs . IsSuccess )
20
22
return tags ;
21
23
22
- var lines = rs . StdOut . Split ( ' \n ' , StringSplitOptions . RemoveEmptyEntries ) ;
23
- foreach ( var line in lines )
24
+ var records = rs . StdOut . Split ( _boundary , StringSplitOptions . RemoveEmptyEntries ) ;
25
+ foreach ( var record in records )
24
26
{
25
- var tag = ParseLine ( line ) ;
26
- if ( tag != null )
27
- tags . Add ( tag ) ;
28
- }
27
+ var subs = record . Split ( '\0 ' , StringSplitOptions . None ) ;
28
+ if ( subs . Length != 4 )
29
+ continue ;
29
30
30
- return tags ;
31
- }
32
-
33
- private Models . Tag ParseLine ( string line )
34
- {
35
- var subs = line . Split ( '$' , StringSplitOptions . RemoveEmptyEntries ) ;
36
- if ( subs . Length == 2 )
37
- {
38
- return new Models . Tag ( )
31
+ var message = subs [ 3 ] . Trim ( ) ;
32
+ tags . Add ( new Models . Tag ( )
39
33
{
40
34
Name = subs [ 0 ] . Substring ( 10 ) ,
41
- SHA = subs [ 1 ] ,
42
- } ;
43
- }
44
- else if ( subs . Length == 3 )
45
- {
46
- return new Models . Tag ( )
47
- {
48
- Name = subs [ 0 ] . Substring ( 10 ) ,
49
- SHA = subs [ 2 ] ,
50
- } ;
35
+ SHA = string . IsNullOrEmpty ( subs [ 2 ] ) ? subs [ 1 ] : subs [ 2 ] ,
36
+ Message = string . IsNullOrEmpty ( message ) ? null : message ,
37
+ } ) ;
51
38
}
52
39
53
- return null ;
40
+ return tags ;
54
41
}
42
+
43
+ private string _boundary = string . Empty ;
55
44
}
56
45
}
0 commit comments