Skip to content

Commit 010b351

Browse files
Minor update
1 parent 4968c77 commit 010b351

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
from os import system
2+
from subprocess import CalledProcessError
3+
from random import choice
4+
from time import sleep, time
5+
6+
commit_messages = ['Minor update', 'Minor', 'Work in progress', 'Minor change', 'Updated code', 'Minor changes']
7+
8+
commit_messages = [
9+
'Minor update',
10+
'Minor',
11+
'Work in progress',
12+
'Minor change',
13+
'Updated code',
14+
'Minor changes',
15+
'Fixing bugs',
16+
'New feature added',
17+
'Code cleanup',
18+
'Optimizing performance',
19+
'Adding new functionality',
20+
'Fixing linting errors',
21+
'Improving usability',
22+
'Adding comments for better understanding',
23+
'Fixing compatibility issues',
24+
'Updating README',
25+
'Merging branches',
26+
'Removing unused code',
27+
'Fixing broken links',
28+
'Adding missing files',
29+
'Improving security',
30+
'Updating dependencies',
31+
'Fixing typos',
32+
'Improving error messages',
33+
'Improving code structure',
34+
'Improving code organization',
35+
'Improving code quality',
36+
'Improving code maintainability',
37+
'Improving code reusability',
38+
'Adding missing validation',
39+
'Adding missing sanitization',
40+
'Improving code readability',
41+
'Adding missing documentation',
42+
'Fixing issues with data handling',
43+
'Improving data validation',
44+
'Improving data security',
45+
'Improving data structure',
46+
'Improving data organization',
47+
'Improving data quality',
48+
'Improving data maintainability',
49+
'Improving data reusability',
50+
'Improving data performance',
51+
'Improving data scalability',
52+
'Improving data efficiency',
53+
'Improving data accuracy',
54+
'Improving data consistency',
55+
'Fixing issues with data input/output',
56+
'Improving data import/export functionality',
57+
'Improving data backup/restore functionality',
58+
'Improving data archiving functionality',
59+
'Improving data recovery functionality'
60+
]
61+
62+
push_after = 20 # in seconds
63+
64+
def print_log(text: str) -> None: print("[[ log ]] {}".format(text))
65+
def print_error(text: str) -> None: print("[[ error ]] {}".format(text))
66+
67+
def run_bash_script(command=None, verbose=True):
68+
"""
69+
Runs a bash script and returns if script was successfully executed or not
70+
"""
71+
if isinstance(command, str):
72+
try:
73+
if verbose: print_log("Running '{}'".format( command ))
74+
start_time = time()
75+
system( command )
76+
if verbose: print_log("Took {} seconds to run '{}'".format( time() - start_time, command ))
77+
return True;
78+
except CalledProcessError:
79+
if verbose: print_error("Something went wrong with {}".format( command ))
80+
return False;
81+
else:
82+
if verbose: print_error("Bash command should be passed as a string")
83+
return False;
84+
85+
def add_to_git():
86+
success = run_bash_script("sh commit.sh '{}'".format( choice(commit_messages) ))
87+
if not success: print_error("Something went wrong when push the code")
88+
89+
def main():
90+
"""
91+
Continuously push code to github
92+
"""
93+
while(True):
94+
add_to_git()
95+
sleep(push_after)
96+
97+
if __name__ == "__main__":
98+
main()

0 commit comments

Comments
 (0)