-
Notifications
You must be signed in to change notification settings - Fork 7k
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
Added script for changelog. #4169
Conversation
if state_file: | ||
try: | ||
if os.path.exists(state_file): | ||
logging.info('Reading state from {}'.format(state_file)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May use %s modifier in logging.level("foo %s", "bar")
and get rid of format
.
groups = {} | ||
|
||
for id, item in pull_requests.items(): | ||
lines = list(filter(len, map(lambda x: x.strip(), item['description'].split('\n')))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
list comprehension more preferable than filter
and map
, but it's ok.
def make_changelog(new_tag, prev_tag, repo, repo_folder, state_file, token, max_retries, retry_timeout): | ||
|
||
base_sha = get_merge_base(new_tag, prev_tag, repo_folder) | ||
logging.info('Base sha: {}\n'.format(base_sha)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redundant new line?
max_retry = args.max_retry | ||
retry_timeout = args.retry_timeout | ||
|
||
logging.basicConfig(level=logging.INFO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
-- much better
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser(description='Make changelog.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add example usage in description or add README.md
|
||
if resp.status_code == 403: | ||
try: | ||
if resp.json()['message'].startswith('API rate limit exceeded') and t < max_retries: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t < max_retries
-- always true?
|
||
texts = [] | ||
for group, text in groups.items(): | ||
items = [u'* {}'.format(pr) for pr in text] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like u'str'
doesn't make sense in python3 https://www.python.org/dev/peps/pep-0414/.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But you want to support python 2, than OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, now it works for both pythons for me.
logging.info('Found {} users.'.format(len(users))) | ||
save_state(state_file, state) | ||
|
||
print(process_pull_requests(pull_requests, users, repo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from __future__ import print_function
add to start of file.
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Category (leave one):
Short description (up to few sentences):
Added script which creates changelog from pull requests description.
Detailed description (optional):
Raw result for last changelog.