def postmortem(date, logger=LOGGER, config=CONFIG): """creates a postmortem file based on completed releases and their unresolved issues. archives release files that are completed using the same date will only append and archive releases as they are updated argument: date of planned postmortem. format: YYYY-MM-DD """ if not date: logger.critical("For now, you must be explicit and specify --date") sys.exit(1) date = sanitize_date_input(date, logger) completed_releases = [release for release in get_releases(config, logger, filter=complete_filter)] postmortem_data_path = os.path.join(config["releasewarrior_data_repo"], config["postmortems"], "{}.json".format(date)) postmortem_wiki_path = os.path.join(config["releasewarrior_data_repo"], config["postmortems"], "{}.md".format(date)) wiki_template = config['templates']["wiki"]["postmortem"] # validate validate_rw_repo(logger, config) if not completed_releases: logger.warning("No recently completed releases. Nothing to do!") sys.exit(1) # make sure archive and postmortem dirs exist for product in config['releases']['archive']: os.makedirs( os.path.join(config['releasewarrior_data_repo'], config['releases']['archive'][product]), exist_ok=True ) os.makedirs(os.path.join(config['releasewarrior_data_repo'], config['postmortems']), exist_ok=True) # get existing postmortem data postmortem_data = { "date": date, "complete_releases": [] } if os.path.exists(postmortem_data_path): postmortem_data = load_json(postmortem_data_path) # archive completed releases for release in completed_releases: _, data_path, wiki_path = get_release_info(release["product"], release["version"], logger, config) # add release to postmortem data postmortem_data["complete_releases"].append(generate_release_postmortem_data(release)) # archive release archive_dir = os.path.join(config["releasewarrior_data_repo"], config["releases"]["archive"][release["product"]]) git.move(data_path, os.path.join(archive_dir, os.path.basename(data_path)), logger, config) git.move(wiki_path, os.path.join(archive_dir, os.path.basename(wiki_path)), logger, config) commit_msg = "updates {} postmortem".format(date) postmortem_data["complete_releases"] = sorted(postmortem_data["complete_releases"], key=lambda x: x["date"]) write_and_commit(postmortem_data, postmortem_data_path, postmortem_wiki_path, commit_msg, logger, config, wiki_template=wiki_template)
def track(product, version, gtb_date, logger=LOGGER, config=CONFIG): """Start tracking an upcoming release. product and version is also used to determine branch. e.g 57.0rc, 57.0.1, 57.0b2, 52.0.1esr """ validate_rw_repo(logger, config) release, data_path, wiki_path = get_release_info(product, version, logger, config) validate(release, logger, config, must_exist=False) data = {} commit_msg = "{} {} started tracking upcoming release.".format(product, version) gtb_date = sanitize_date_input(gtb_date, logger) data = get_tracking_release_data(release, gtb_date, logger, config) write_and_commit(data, data_path, wiki_path, commit_msg, logger, config)