|
6 | 6 |
|
7 | 7 | def add_random_letter_to_file(repo, file_name): |
8 | 8 | command = f'cd {repo} && echo "a" >> {file_name}' |
9 | | - subprocess.call(command, shell=True, stdout=subprocess.DEVNULL) |
| 9 | + subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
10 | 10 |
|
11 | 11 | def git_add_all_to_stage(repo): |
12 | 12 | command = f'cd {repo} && git add .' |
13 | | - subprocess.call(command, shell=True, stdout=subprocess.DEVNULL) |
| 13 | + subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
14 | 14 |
|
15 | 15 | def git_commit_with_specified_date(repo, date, commit_message = None): |
16 | 16 | command = f'cd {repo} && git commit --date="{date}" -m "{date}"' |
17 | | - subprocess.call(command, shell=True, stdout=subprocess.DEVNULL) |
| 17 | + subprocess.call(command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
18 | 18 |
|
19 | 19 | def make_commit_with_specified_date(repo, date, commit_message = None): |
20 | 20 | add_random_letter_to_file(repo, "test") |
@@ -43,18 +43,22 @@ def clone_repo_if_not_exists_already(username, repo, protocol = "ssh"): |
43 | 43 | def execute(repo, date, numbers_of_commits_per_day = 1): |
44 | 44 | commits = 0 |
45 | 45 | total_commits = len(dates) * numbers_of_commits_per_day |
| 46 | + time_per_commit = None |
46 | 47 | print("Info:") |
47 | 48 | print(f"Number of dates: {len(dates)}") |
48 | 49 | print(f"Number of commits per day: {numbers_of_commits_per_day}") |
49 | 50 | print(f"Number of commits: {total_commits}") |
50 | 51 | print("-" * 70) |
51 | 52 | for date in dates: |
52 | 53 | for i in range(numbers_of_commits_per_day): |
53 | | - start_time = datetime.now() |
54 | | - make_commit_with_specified_date(repo, date) |
55 | | - end_time = datetime.now() |
56 | | - total_seconds = (end_time - start_time).total_seconds() |
57 | | - eta = total_seconds * (total_commits - commits) |
| 54 | + if not time_per_commit: |
| 55 | + start_time = datetime.now() |
| 56 | + make_commit_with_specified_date(repo, date) |
| 57 | + end_time = datetime.now() |
| 58 | + time_per_commit = (end_time - start_time).total_seconds() |
| 59 | + else: |
| 60 | + make_commit_with_specified_date(repo, date) |
| 61 | + eta = time_per_commit * (total_commits - commits) |
58 | 62 | formatted_eta = str(timedelta(seconds=int(eta))) |
59 | 63 | commits += 1 |
60 | 64 | percentage = (commits / total_commits) * 100 |
|
0 commit comments