Skip to content

Commit e61a9e4

Browse files
authored
44 Использование "default" ветки по умолчанию (#46)
* fix: default branch name for unset flag 'branch' * update: help text for flag -b
1 parent 776bfa8 commit e61a9e4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

git_logger.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,14 @@ def log_repository_commits(repository: Repository, csv_name, start, finish, bran
7373

7474

7575
branches = []
76-
if branch == 'all':
77-
for branch in repository.get_branches():
78-
branches.append(branch.name)
79-
else:
80-
branches.append(branch)
76+
match branch:
77+
case 'all':
78+
for branch in repository.get_branches():
79+
branches.append(branch.name)
80+
case None:
81+
branches.append(repository.default_branch)
82+
case _:
83+
branches.append(branch)
8184

8285
#print(branches)
8386

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def parse_args():
1616
parser.add_argument('-o', '--out', type=str, required=True, help='output filename')
1717
parser.add_argument('-s', '--start', type=str, required=False, help='start time', default='2000/01/01-00:00:00')
1818
parser.add_argument('-f', '--finish', type=str, required=False, help='finish time', default='2400/01/01-00:00:00')
19-
parser.add_argument('-b', '--branch', type=str, required=False, help='branch to select commits, default "main", use "all" to get all commits from all branches', default='main')
19+
parser.add_argument('-b', '--branch', type=str, required=False, help='branch to select commits, by default use "default" repository branch, use "all" to get all commits from all branches', default=None)
2020
parser.add_argument('--google_token', type=str, required=False, help='Specify path to google token file')
2121
parser.add_argument('--table_id', type=str, required=False,
2222
help='Specify Google sheet document id (can find in url)')

0 commit comments

Comments
 (0)