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

Added script for changelog. #4169

Merged
merged 1 commit into from Jan 28, 2019
Merged

Added script for changelog. #4169

merged 1 commit into from Jan 28, 2019

Conversation

KochetovNicolai
Copy link
Member

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Category (leave one):

  • Other

Short description (up to few sentences):
Added script which creates changelog from pull requests description.

Detailed description (optional):
Raw result for last changelog.

@alesapin alesapin added the do not test disable testing on pull request label Jan 28, 2019
@alesapin alesapin self-assigned this Jan 28, 2019
if state_file:
try:
if os.path.exists(state_file):
logging.info('Reading state from {}'.format(state_file))
Copy link
Member

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'))))
Copy link
Member

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))
Copy link
Member

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)
Copy link
Member

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.')
Copy link
Member

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:
Copy link
Member

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]
Copy link
Member

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/.

Copy link
Member

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.

Copy link
Member Author

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))
Copy link
Member

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.

@alexey-milovidov alexey-milovidov merged commit 25e0f56 into master Jan 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not test disable testing on pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants