Skip to content

Commit abff6af

Browse files
authored
Properly handle branch, default to main (#154)
1 parent 7a13fb7 commit abff6af

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

github_activity/github_activity.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,11 @@ def filter_ignored(userlist):
690690
this_md = f"- {ititle} [#{irowdata['number']}]({irowdata['url']}) ({contributor_list})"
691691
items["md"].append(this_md)
692692

693-
# Get functional GitHub references: any git reference or master@{YY-mm-dd}
693+
# Get functional GitHub references: any git reference or {branch}@{YY-mm-dd}
694+
# Use the branch parameter if provided, otherwise default to "main"
695+
ref_branch = branch or "main"
694696
if closed_prs.size > 0 and not data.since_is_git_ref:
695-
since = f"master@{{{data.since_dt:%Y-%m-%d}}}"
697+
since = f"{ref_branch}@{{{data.since_dt:%Y-%m-%d}}}"
696698
closest_date_start = closed_prs.loc[
697699
abs(
698700
pd.to_datetime(closed_prs["closedAt"], utc=True)
@@ -704,7 +706,7 @@ def filter_ignored(userlist):
704706
since_ref = since
705707

706708
if closed_prs.size > 0 and not data.until_is_git_ref:
707-
until = f"master@{{{data.until_dt:%Y-%m-%d}}}"
709+
until = f"{ref_branch}@{{{data.until_dt:%Y-%m-%d}}}"
708710
closest_date_stop = closed_prs.loc[
709711
abs(
710712
pd.to_datetime(closed_prs["closedAt"], utc=True)

tests/test_cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"github-activity {org}/{repo} -s 2021-01-01 -u 2021-01-15 -o {path_output}",
1919
"cli_w_parts",
2020
),
21-
# CLI with default branch
21+
# CLI with explicit branch filter (using master since that was likely the name in 2021)
2222
(
2323
"github-activity {org}/{repo} -s 2021-01-01 -u 2021-01-15 -o {path_output} -b master",
2424
"cli_def_branch",

tests/test_cli/cli_no_target.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# master@{2021-01-01}...master@{2021-01-15}
1+
# main@{2021-01-01}...main@{2021-01-15}
22

33
([full changelog](https://github.com/executablebooks/github-activity/compare/c740a454def057304556675ce7694dc0f2eb6c88...c740a454def057304556675ce7694dc0f2eb6c88))
44

tests/test_cli/cli_no_target_pyproject.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
##### master@{2021-01-01}...master@{2021-01-15}
1+
##### main@{2021-01-01}...main@{2021-01-15}
22

33
([full changelog](https://github.com/executablebooks/github-activity/compare/c740a454def057304556675ce7694dc0f2eb6c88...c740a454def057304556675ce7694dc0f2eb6c88))
44

tests/test_cli/cli_w_parts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# master@{2021-01-01}...master@{2021-01-15}
1+
# main@{2021-01-01}...main@{2021-01-15}
22

33
([full changelog](https://github.com/executablebooks/github-activity/compare/c740a454def057304556675ce7694dc0f2eb6c88...c740a454def057304556675ce7694dc0f2eb6c88))
44

tests/test_cli/cli_w_url.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# master@{2021-01-01}...master@{2021-01-15}
1+
# main@{2021-01-01}...main@{2021-01-15}
22

33
([full changelog](https://github.com/executablebooks/github-activity/compare/c740a454def057304556675ce7694dc0f2eb6c88...c740a454def057304556675ce7694dc0f2eb6c88))
44

0 commit comments

Comments
 (0)