Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contribution_utils to license_utils for more complete unit testing #271

Merged
merged 17 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions CONTRIBUTORS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
{
"forked_at": "2017-11-27T11:53:17-05:00",
"excluded_fork": null,
"pre_fork_contributors_by_name": null,
"contributors_by_name": {
"Alex Balashov": {
"emails": [
"[email protected]"
],
"names": [
"Alex Balashov",
"Alexander Balashov"
]
},
"Alexander Veit": {
"emails": [
"[email protected]"
],
"names": [
"Alexander Veit"
]
},
"Andrea Cosolo": {
"emails": [
"[email protected]"
],
"names": [
"Andrea Cosolo"
]
},
"Andy Schroeder": {
"emails": [
"[email protected]"
],
"names": [
"Andy Schroeder",
"aschroed"
]
},
"Carl Vitzthum": {
"emails": [
"[email protected]",
"[email protected]"
],
"names": [
"Carl Vitzthum"
]
},
"David Michaels": {
"emails": [
"[email protected]",
"[email protected]",
"[email protected]"
],
"names": [
"David Michaels",
"dmichaels-harvard"
]
},
"Douglas Rioux": {
"emails": [
"[email protected]",
"[email protected]"
],
"names": [
"Douglas Rioux",
"drio18"
]
},
"Eric Berg": {
"emails": [
"[email protected]"
],
"names": [
"Eric Berg"
]
},
"Jeremy Johnson": {
"emails": [
"[email protected]"
],
"names": [
"Jeremy Johnson",
"j1z0"
]
},
"Kent M Pitman": {
"emails": [
"[email protected]",
"[email protected]"
],
"names": [
"Kent M Pitman",
"Kent Pitman"
]
},
"Koray K\u0131rl\u0131": {
"emails": [
"[email protected]",
"[email protected]"
],
"names": [
"Koray K\u0131rl\u0131"
]
Comment on lines +97 to +104
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like something that may need correcting in encoding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I think it's safer this way. It will output correctly. It can be read by the default python reader and it will display as real unicode if you print it out in a regular file or on the terminal.

},
"Luisa Mercado": {
"emails": [
"[email protected]"
],
"names": [
"Lmercadom",
"Luisa Mercado"
]
},
"Sarah Reiff": {
"emails": [
"[email protected]"
],
"names": [
"Sarah",
"Sarah Reiff"
]
},
"Soo Lee": {
"emails": [
"[email protected]"
],
"names": [
"Soo Lee",
"SooLee"
]
},
"Will Ronchetti": {
"emails": [
"[email protected]"
],
"names": [
"Will Ronchetti",
"William Ronchetti"
]
}
}
}
39 changes: 39 additions & 0 deletions dcicutils/contribution_scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import argparse

from dcicutils.command_utils import script_catch_errors, ScriptFailure
from .contribution_utils import Contributions, PROJECT_HOME


EPILOG = __doc__


def show_contributors(repo, exclude_fork=None, verbose=False, save_contributors=False, test=False):
contributions = Contributions(repo=repo, exclude_fork=exclude_fork, verbose=verbose)
if save_contributors:
contributions.save_contributor_data()
contributions.show_repo_contributors(error_class=ScriptFailure if test else None)


def show_contributors_main(*, simulated_args=None):
parser = argparse.ArgumentParser( # noqa - PyCharm wrongly thinks the formatter_class is specified wrong here.
description=(f"Show authors of a specified repository, which will be presumed"
f" to have been cloned as a subdirectory of $PROJECT_HOME ({PROJECT_HOME})"),
epilog=EPILOG,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument('repo', default=None,
help="name of repository to show contributors for")
parser.add_argument('--exclude', '-x', default=None,
help="name of repository that repo was forked from, whose contributors to exclude")
parser.add_argument('--save-contributors', '-s', action="store_true", default=False,
help="whether to store contributor data to CONTRIBUTORS.json")
parser.add_argument('--test', '-t', action="store_true", default=False,
help="whether to treat this as a test, erring if a cache update is needed")
parser.add_argument('--verbose', '-v', action="store_true", default=False,
help="whether to do verbose output while working")
args = parser.parse_args(args=simulated_args)

with script_catch_errors():

show_contributors(repo=args.repo, exclude_fork=args.exclude, verbose=args.verbose,
save_contributors=args.save_contributors, test=args.test)
Loading