self.write_commit_details(commit, f) output_val = self.output_value(f) finally: f.close() self.log("Finished writing commit summary for {0}".format(commit)) return output_val def link(self, compilation_output, linking_options): '''Combine all the commit summaries into a single commit summary report.''' commits = compilation_output.keys() commits.sort(key=lambda c: c.committed_date) # TODO abstract this since this is something that would be commonly done. with open('commit_summary_report.txt', 'w') as report: for commit in commits: output = compilation_output[commit] if self.output_to_files: with open(output, 'r') as output_file: output = output_file.read() print >> report, "-------------------" print >> report, output print >> report, "-------------------" if __name__ == '__main__': from gcc.git_compiler import GitCompiler compiler = GitCompiler('.') compiler.add_commit_targets(rev='master') commit_summary = CommitSummary() compiler.set_compilation_task(CompilationTask(commit_summary)) compiler.set_linking_task(LinkingTask(commit_summary)) compiler.compile(link=True)
commits = compilation_output.keys() commits.sort(key=lambda c: -c.committed_date) # newest first release_history = defaultdict(list) for commit in commits: tag, title = compilation_output[commit] if tag and title: release_history[tag].append(title) else: self.log("Not writing tag: {0} title: {1}".format(tag, title)) tags = sorted(release_history.keys()) tags.reverse() for tag in tags: print >> history_file, "\n{0}\n========".format(tag) for title in release_history[tag]: print >> history_file, "* {0}".format(title) self.log("Wrote {0} for {1}".format(title, tag)) finally: history_file.close() if __name__ == '__main__': from gcc.git_compiler import GitCompiler import sys compiler = GitCompiler(len(sys.argv) > 1 and sys.argv[1] or ".") # Take the first argument as the repo path or assume the current directory is the repo if no args are provided. git = compiler.git_manager compiler.add_commit_targets(from_ref=git.first_commit, to_ref=git.last_commit, filter_function=git.PULL_REQUEST_FILTER) compiler.set_compilation_task(PRCollect()) compiler.set_linking_task(HistoryMDLinker()) compiler.compile(link=True)