13
13
14
14
### {{ files_to_be_modified | count }} files to be modified
15
15
{% for m_file in files_to_be_modified -%}
16
- 1. [ ] {{ m_file.filepath }} {{ m_file.shortstat }}
16
+ 1. [ ] {{ m_file.fileindex }} `{{ m_file. filepath }}` {{ m_file.stat }}
17
17
{% endfor %}
18
18
19
19
### {{ files_to_be_renamed | count }} files to be renamed
20
20
{% for r_file in files_to_be_renamed -%}
21
- 1. [ ] {{ r_file.diff_status_letter }} {{ r_file.src_filepath }} -> {{ r_file.dest_filepath }}
21
+ 1. [ ] {{ r_file.fileindex }} {{ r_file. diff_status_letter }} ` {{ r_file.src_filepath }}` -> ` {{ r_file.dest_filepath }}`
22
22
{% endfor %}
23
23
24
24
### {{ files_to_be_deleted | count }} files to be deleted
25
25
{% for d_file in files_to_be_deleted -%}
26
- 1. [ ] {{ d_file }}
26
+ 1. [ ] {{ d_file.fileindex }} `{{ d_file.filepath }}`
27
27
{% endfor %}
28
28
29
29
## Proposed Solution
51
51
52
52
## Pages to Update
53
53
54
+ Pages in {{ l10n_lang_path }}
55
+
54
56
"""
55
57
56
58
files_to_be_deleted = []
57
59
files_to_be_renamed = []
58
60
files_to_be_modified = []
59
61
62
+ index_to_be_deleted = 0
63
+ index_to_be_renamed = 0
64
+ index_to_be_modified = 0
60
65
61
- def git_diff (filepath , l_commit , r_commit , shortstat = False ):
66
+ def git_diff (filepath , l_commit , r_commit , stat = False ):
62
67
cmd = ["git" , "diff" , l_commit , r_commit , "--" , filepath ]
63
68
64
- if shortstat :
65
- cmd = ["git" , "diff" , l_commit , r_commit , "--shortstat " , "--" , filepath ]
69
+ if stat :
70
+ cmd = ["git" , "diff" , l_commit , r_commit , "--stat " , "--" , filepath ]
66
71
67
72
return subprocess .check_output (cmd ).decode ("UTF-8" ).strip ()
68
73
@@ -78,18 +83,70 @@ def process_diff_status(diff_status, l_commit, r_commit, src_lang_path,
78
83
status_letter = diff_status [0 ]
79
84
filepath = diff_status [1 ]
80
85
86
+ size_xs = 10
87
+ size_s = 30
88
+ size_m = 100
89
+ size_l = 500
90
+ size_xl = 1000
91
+
81
92
if git_exists (r_commit , filepath .replace (src_lang_path , l10n_lang_path )):
82
93
if status_letter == 'D' :
83
- files_to_be_deleted .append (filepath )
94
+ global index_to_be_deleted
95
+ index_to_be_deleted += 1
96
+ fileindex = "D" + str (index_to_be_deleted ) + '. '
97
+ deleted = {"fileindex" : fileindex ,
98
+ "filepath" : filepath }
99
+ files_to_be_deleted .append (deleted )
84
100
elif status_letter .startswith ('R' ):
85
- replaced = {"diff_status_letter" : diff_status [0 ],
101
+ global index_to_be_renamed
102
+ index_to_be_renamed += 1
103
+ fileindex = "R" + str (index_to_be_renamed ) + '. '
104
+ replaced = {"fileindex" : fileindex ,
105
+ "diff_status_letter" : diff_status [0 ],
86
106
"src_filepath" : diff_status [1 ],
87
107
"dest_filepath" : diff_status [2 ]}
88
108
files_to_be_renamed .append (replaced )
89
109
elif status_letter == 'M' :
90
- modified = {"filepath" : filepath ,
91
- "shortstat" : git_diff (filepath , l_commit , r_commit ,
92
- shortstat = True ),
110
+ global index_to_be_modified
111
+ index_to_be_modified += 1
112
+ diff_string = git_diff (filepath , l_commit , r_commit , stat = True )
113
+ diff_string_tmp = diff_string .split ("|" )
114
+ diff_string_r = diff_string_tmp [1 ]
115
+
116
+ res = [int (i ) for i in diff_string_r .split () if i .isdigit ()]
117
+ if len (res ) < 4 :
118
+ res .append (0 )
119
+
120
+ insertions = res [2 ]
121
+ deletions = res [3 ]
122
+
123
+ bold_condition = size_m
124
+ if insertions < size_xs :
125
+ insertion_size = "XS"
126
+ elif insertions < size_s :
127
+ insertion_size = "S"
128
+ elif insertions < size_m :
129
+ insertion_size = "M"
130
+ elif insertions < size_l :
131
+ insertion_size = "L"
132
+ elif insertions < size_xl :
133
+ insertion_size = "XL"
134
+ else :
135
+ insertion_size = "XXL"
136
+
137
+ stat_output = str (insertions ) + "(+" + insertion_size + ") " + str (deletions ) + "(-)"
138
+
139
+ if insertions >= bold_condition :
140
+ fileindex = "**M" + str (index_to_be_modified ) + ".** "
141
+ stat_output = "**" + stat_output + "**"
142
+ else :
143
+ fileindex = "M" + str (index_to_be_modified ) + ". "
144
+
145
+ stat_output = " | " + stat_output
146
+
147
+ modified = {"fileindex" : fileindex ,
148
+ "filepath" : filepath ,
149
+ "stat" : stat_output ,
93
150
"diff" : git_diff (filepath , l_commit , r_commit )}
94
151
files_to_be_modified .append (modified )
95
152
0 commit comments