Skip to content

Commit

Permalink
style: rename ltp to link_to_profile
Browse files Browse the repository at this point in the history
  • Loading branch information
jellllly420 committed Jan 10, 2024
1 parent 115b6f9 commit ed6e0a6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions contributors.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main():
start_date,
end_date,
sponsor_info,
ltp
link_to_profile
) = env.get_env_vars()

# Auth to GitHub.com
Expand Down Expand Up @@ -65,7 +65,7 @@ def main():
organization,
repository_list,
sponsor_info,
ltp
link_to_profile
)
# write_to_json(contributors)

Expand Down
12 changes: 6 additions & 6 deletions env.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ def get_env_vars() -> (
"SPONSOR_INFO environment variable not a boolean. ie. True or False or blank"
)

ltp = os.getenv("LINK_TO_PROFILE")
# make sure that ltp is a boolean
if ltp:
ltp = ltp.lower().strip()
if ltp not in ["true", "false", ""]:
link_to_profile = os.getenv("LINK_TO_PROFILE")
# make sure that link_to_profile is a boolean
if link_to_profile:
link_to_profile = link_to_profile.lower().strip()
if link_to_profile not in ["true", "false", ""]:
raise ValueError(
"LINK_TO_PROFILE environment variable not a boolean. ie. True or False or blank"
)
Expand All @@ -92,5 +92,5 @@ def get_env_vars() -> (
start_date,
end_date,
sponsor_info,
ltp,
link_to_profile,
)
12 changes: 6 additions & 6 deletions markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def write_to_markdown(
organization,
repository,
sponsor_info,
ltp
link_to_profile
):
"""
This function writes a list of collaborators to a markdown file in table format.
Expand All @@ -25,15 +25,15 @@ def write_to_markdown(
organization (str): The organization for which the contributors are being listed.
repository (str): The repository for which the contributors are being listed.
sponsor_info (str): True if the user wants the sponsor_url shown in the report
ltp (str): True if the user wants the username linked to Github profile in the report
link_to_profile (str): True if the user wants the username linked to Github profile in the report
Returns:
None
"""
# Put together the contributor table
table, total_contributions = get_contributor_table(
collaborators, start_date, end_date, organization, repository, sponsor_info, ltp
collaborators, start_date, end_date, organization, repository, sponsor_info, link_to_profile
)

# Put together the summary table including # of new contributions, # of new contributors, % new contributors, % returning contributors
Expand Down Expand Up @@ -129,7 +129,7 @@ def get_summary_table(collaborators, start_date, end_date, total_contributions):


def get_contributor_table(
collaborators, start_date, end_date, organization, repository, sponsor_info, ltp
collaborators, start_date, end_date, organization, repository, sponsor_info, link_to_profile
):
"""
This function returns a string containing a markdown table of the contributors and the total contribution count.
Expand All @@ -142,7 +142,7 @@ def get_contributor_table(
organization (str): The organization for which the contributors are being listed.
repository (str): The repository for which the contributors are being listed.
sponsor_info (str): True if the user wants the sponsor_url shown in the report
ltp (str): True if the user wants the username linked to Github profile in the report
link_to_profile (str): True if the user wants the username linked to Github profile in the report
Returns:
table (str): A string containing a markdown table of the contributors and the total contribution count.
Expand Down Expand Up @@ -180,7 +180,7 @@ def get_contributor_table(
commit_urls += url + ", "
new_contributor = collaborator.new_contributor

row = f"| {'' if ltp == 'false' else '@'}{username} | {contribution_count} |"
row = f"| {'' if link_to_profile == 'false' else '@'}{username} | {contribution_count} |"
if "New Contributor" in columns:
row += f" {new_contributor} |"
if "Sponsor URL" in columns:
Expand Down
4 changes: 2 additions & 2 deletions test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_get_env_vars(self, mock_getenv):
start_date,
end_date,
sponsor_info,
ltp
link_to_profile
) = env.get_env_vars()

self.assertEqual(organization, "org")
Expand All @@ -45,7 +45,7 @@ def test_get_env_vars(self, mock_getenv):
self.assertEqual(start_date, "2022-01-01")
self.assertEqual(end_date, "2022-12-31")
self.assertEqual(sponsor_info, "false")
self.assertEqual(ltp, 'true')
self.assertEqual(link_to_profile , 'true')

@patch("os.getenv")
def test_get_env_vars_missing_values(self, mock_getenv):
Expand Down

0 comments on commit ed6e0a6

Please sign in to comment.