def main(): # ---------- # Parse Args args = argparse_create().parse_args() def is_credit_commit_valid(c): ignore_dir = ( b"blender/extern/", b"blender/intern/opennl/", ) if not any(f for f in c.files if not f.startswith(ignore_dir)): return False return True # TODO, there are for sure more companies then are currently listed. # 1 liners for in html syntax contrib_companies = ( "<b>Unity Technologies</b> - FBX Exporter", "<b>BioSkill GmbH</b> - H3D compatibility for X3D Exporter, " "OBJ Nurbs Import/Export", "<b>AutoCRC</b> - Improvements to fluid particles, vertex color baking", "<b>Adidas</b> - Principled BSDF shader in Cycles", "<b>AMD</b> - Cycles HIP GPU rendering, CPU optimizations", "<b>Intel</b> - Cycles ray-tracing optimization", "<b>NVidia</b> - Cycles OptiX GPU rendering, USD importer", "<b>Facebook</b> - Cycles subsurface scattering improvements", ) credits = Credits() # commit_range = "HEAD~10..HEAD" # commit_range = "blender-v2.81-release..blender-v2.82-release" # commit_range = "blender-v2.82-release" commit_range = args.range_sha1 citer = GitCommitIter(args.source_dir, commit_range) credits.process((c for c in citer if is_credit_commit_valid(c))) credits.write("credits.html", is_main_credits=True, contrib_companies=contrib_companies) print("Written: credits.html")
def main(): # ---------- # Parse Args args = argparse_create().parse_args() def is_credit_commit_valid(c): ignore_dir = ( b"blender/extern/", b"blender/intern/opennl/", b"blender/intern/moto/", ) if not any(f for f in c.files if not f.startswith(ignore_dir)): return False return True # TODO, there are for sure more companies then are currently listed. # 1 liners for in html syntax contrib_companies = ( "<b>Unity Technologies</b> - FBX Exporter", "<b>BioSkill GmbH</b> - H3D compatibility for X3D Exporter, " "OBJ Nurbs Import/Export", "<b>AutoCRC</b> - Improvements to fluid particles, vertex color baking", ) credits = Credits() # commit_range = "HEAD~10..HEAD" commit_range = args.range_sha1 citer = GitCommitIter(args.source_dir, commit_range) credits.process((c for c in citer if is_credit_commit_valid(c))) credits.write("credits.html", is_main_credits=True, contrib_companies=contrib_companies) print("Written: credits.html")
def main(): ACCEPT_FILE = "review_accept.txt" REJECT_FILE = "review_reject.txt" # ---------- # Parse Args args = argparse_create().parse_args() from git_log import GitCommit, GitCommitIter # -------------- # Filter Commits def match(c): # filter_type if not args.filter_type: pass elif args.filter_type == 'BUGFIX': first_line = c.body.strip().split("\n")[0] assert (len(first_line)) if any(w for w in first_line.split() if w.lower().startswith(("fix", "bugfix", "bug-fix"))): pass else: return False elif args.filter_type == 'NOISE': first_line = c.body.strip().split("\n")[0] assert (len(first_line)) if any(w for w in first_line.split() if w.lower().startswith("cleanup")): pass else: return False else: raise Exception("Filter type %r isn't known" % args.filter_type) # author if not args.author: pass elif args.author != c.author: return False return True commits = [ c for c in GitCommitIter(args.source_dir, args.range_sha1) if match(c) ] # oldest first commits.reverse() tot_accept = 0 tot_reject = 0 def exit_message(): print( " Written", colorize(ACCEPT_FILE, color='green'), "(%d)" % tot_accept, colorize(REJECT_FILE, color='red'), "(%d)" % tot_reject, ) for i, c in enumerate(commits): if os.name == "posix": # also clears scrollback os.system("tput reset") else: print('\x1b[2J') # clear sha1 = c.sha1 # diff may scroll off the screen, that's OK os.system("git --git-dir %s show %s --format=%%n" % (c._git_dir, sha1.decode('ascii'))) print("") print_commit(c) sys.stdout.flush() # print(ch) while True: print( "Space=" + colorize("Accept", 'green'), "Enter=" + colorize("Skip", 'red'), "Ctrl+C or Q=" + colorize("Quit", color='white'), "[%d of %d]" % (i + 1, len(commits)), "(+%d | -%d)" % (tot_accept, tot_reject), ) ch = getch() if ch == b'\x03' or ch == b'q': # Ctrl+C exit_message() print("Goodbye! (%s)" % c.sha1.decode()) return elif ch == b' ': log_filepath = ACCEPT_FILE tot_accept += 1 break elif ch == b'\r': log_filepath = REJECT_FILE tot_reject += 1 break else: print("Unknown input %r" % ch) with open(log_filepath, 'ab') as f: f.write(sha1 + b'\n') exit_message()
def main(): # ---------- # Parse Args args = argparse_create().parse_args() for path in args.filter_exclude_sha1_filepaths: if os.path.exists(path): with open(path, 'r') as f: args.filter_exclude_sha1_list += [ sha1 for l in f for sha1 in l.split() ] args.filter_exclude_sha1_list = { sha1.encode() for sha1 in args.filter_exclude_sha1_list } messages = set() for path in args.filter_exclude_releaselogs: messages |= release_log_extract_messages(path) args.filter_exclude_releaselogs = messages from git_log import GitCommit, GitCommitIter # -------------- # Filter Commits def match(c): # filter_type if not args.filter_type: pass elif args.filter_type == 'BUGFIX': first_line = c.body.split("\n\n")[0].strip(" :.;-\n").replace( "\n", " ") assert (len(first_line)) if any(w for w in first_line.split() if w.lower().startswith(("fix", "bugfix", "bug-fix"))): pass else: return False elif args.filter_type == 'NOISE': first_line = c.body.strip().split("\n")[0] assert (len(first_line)) if any(w for w in first_line.split() if w.lower().startswith("cleanup")): pass else: return False else: raise Exception("Filter type %r isn't known" % args.filter_type) # author if not args.author: pass elif args.author != c.author: return False # commits to exclude if c.sha1 in args.filter_exclude_sha1_list: return False # exclude by commit message (because cherry-pick totally breaks relations with original commit...) if args.filter_exclude_releaselogs: if gen_commit_message_pretty(c) in args.filter_exclude_releaselogs: return False return True if args.accept_releaselog: blender_rev = args.blender_rev or "<UNKNOWN>" commits = tuple(GitCommitIter(args.source_dir, args.range_sha1)) release_log = release_log_init(ACCEPT_RELEASELOG_FILE, args.source_dir, blender_rev, commits[-1].sha1.decode(), commits[0].sha1.decode(), args.blender_rstate, args.blender_rstate_list) commits = [c for c in commits if match(c)] else: commits = [ c for c in GitCommitIter(args.source_dir, args.range_sha1) if match(c) ] # oldest first commits.reverse() tot_accept = 0 tot_reject = 0 def exit_message(): print( " Written", colorize(ACCEPT_FILE, color='green'), "(%d)" % tot_accept, colorize(ACCEPT_LOG_FILE, color='yellow'), "(%d)" % tot_accept, colorize(ACCEPT_PRETTY_FILE, color='blue'), "(%d)" % tot_accept, colorize(REJECT_FILE, color='red'), "(%d)" % tot_reject, ) def get_cat(ch, max_idx): cat = -1 try: cat = int(ch) except: pass if 0 <= cat < max_idx: return cat print("Invalid input %r" % ch) return None for i, c in enumerate(commits): if os.name == "posix": # Also clears scroll-back. os.system("tput reset") else: print('\x1b[2J') # clear sha1 = c.sha1 # diff may scroll off the screen, that's OK os.system("git --git-dir %s show %s --format=%%n" % (c._git_dir, sha1.decode('ascii'))) print("") print_commit(c) sys.stdout.flush() accept = False while True: print( "Space=" + colorize("Accept", 'green'), "Enter=" + colorize("Skip", 'red'), "Ctrl+C or X=" + colorize("Exit", color='white'), "[%d of %d]" % (i + 1, len(commits)), "(+%d | -%d)" % (tot_accept, tot_reject), ) ch = getch() if ch == b'\x03' or ch == b'x': # Ctrl+C exit_message() print("Goodbye! (%s)" % c.sha1.decode()) return False elif ch == b' ': log_filepath = ACCEPT_FILE log_filepath_log = ACCEPT_LOG_FILE log_filepath_pretty = ACCEPT_PRETTY_FILE tot_accept += 1 if args.accept_releaselog: # Enter sub-loop for category selection. done_main = True c1 = c2 = None while True: if c1 is None: print( "Select main category (V=View all categories, M=Commit message): \n\t%s" "" % " | ".join("[%d] %s" % (i, cat[0]) for i, cat in enumerate( BUGFIX_CATEGORIES))) else: main_cat = BUGFIX_CATEGORIES[c1][0] sub_cats = BUGFIX_CATEGORIES[c1][1] if not sub_cats: break print( "[%d] %s: Select sub category " "(V=View all categories, M=Commit message, Enter=No sub-categories, " "Backspace=Select other main category): \n\t%s" "" % (c1, main_cat, " | ".join( "[%d] %s" % (i, cat) for i, cat in enumerate(sub_cats)))) ch = getch() if ch == b'\x7f': # backspace done_main = False break elif ch == b'\x03' or ch == b'x': # Ctrl+C exit_message() print("Goodbye! (%s)" % c.sha1.decode()) return elif ch == b'v': print_categories_tree() print("") elif ch == b'm': print_commit(c) print("") elif c1 is None: c1 = get_cat(ch, len(BUGFIX_CATEGORIES)) elif c2 is None: if ch == b'\r': break elif ch == b'\x7f': # backspace c1 = None continue c2 = get_cat(ch, len(BUGFIX_CATEGORIES[c1][1])) if c2 is not None: break else: print("BUG! this should not happen!") if done_main is False: # Go back to main loop, this commit is no more accepted nor rejected. tot_accept -= 1 continue write_release_log(ACCEPT_RELEASELOG_FILE, release_log, c, (c1, c2), args.blender_rstate, args.blender_rstate_list) break elif ch == b'\r': log_filepath = REJECT_FILE log_filepath_log = None log_filepath_pretty = None tot_reject += 1 break else: print("Invalid input %r" % ch) with open(log_filepath, 'ab') as f: f.write(sha1 + b'\n') if args.accept_pretty and log_filepath_pretty: with open(log_filepath_pretty, 'a') as f: f.write( gen_commit_pretty(c, rstate=args.blender_rstate) + "\n") if args.accept_log and log_filepath_log: with open(log_filepath_log, 'a') as f: f.write(gen_commit_log(c) + "\n") exit_message()