7
7
pattern_translated_strings = r'Translated:\s+(\d+)'
8
8
9
9
10
- def run_git_command (command ):
10
+ def run_os_command (command ):
11
11
try :
12
12
return os .popen (command ).read ()
13
13
except Exception as e :
14
- print (f"Error executing Git command: { e } " )
14
+ print (f"Error executing OS command: { e } " )
15
15
return ""
16
16
17
17
18
18
def get_translated_commit_strings (commit_hash ):
19
19
try :
20
- run_git_command (f"git switch { commit_hash } --detach" )
21
- output = os . popen (f"pocount { absolute_path } /*.po { absolute_path } /**/*.po" ). read ( )
22
- all_translated_results = re .findall (pattern_translated_strings , output , re .DOTALL )
23
- translated_commit_strings = int (all_translated_results [- 1 ])
24
- return translated_commit_strings
20
+ run_os_command (f"git switch --force { commit_hash } --detach" )
21
+ pocount_of_commit = run_os_command (f"pocount { absolute_path } /*.po { absolute_path } /**/*.po" )
22
+ all_translated_results = re .findall (pattern_translated_strings , pocount_of_commit , re .DOTALL )
23
+ total_of_translated_commit_strings = int (all_translated_results [- 1 ])
24
+ return total_of_translated_commit_strings
25
25
except Exception as e :
26
26
print (f"Error getting translated strings count: { e } " )
27
27
return 0
@@ -35,9 +35,3 @@ def get_difference_between_translated_commits_strings(commit_hash1, commit_hash2
35
35
except Exception as e :
36
36
print (f"Error calculating the difference between translated strings counts: { e } " )
37
37
return 0
38
-
39
-
40
- hash1 = "69ff2f8a3141f5aad0f968e76675830a158660c6"
41
- hash2 = "fa5d1cea27abe701398ee8fe7ee5ba285fafeee2"
42
-
43
- print (get_difference_between_translated_commits_strings (hash1 , hash2 ))
0 commit comments