Created
April 23, 2013 19:09
Revisions
-
Jd007 created this gist
Apr 23, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ def extract_git_log_by_hashes(hash_file_path, raw_log_path, output_file_path): f = open(hash_file_path, 'r') hashes = [] for h in f: hashes.append(str(h).strip()) f.close() raw_log_file = open(raw_log_path, 'r') processed_data = {} is_in_block = False current_block_text = '' current_hash = '' for line in raw_log_file: if not is_in_block: for h in hashes: start_trigger = 'commit ' + h if start_trigger in str(line): current_block_text += line current_hash = h is_in_block = True break else: current_block_text += line if 'file' in line and 'changed' in line and ('insertion' in line or 'deletion' in line): processed_data[current_hash] = current_block_text current_block_text = '' current_hash = '' is_in_block = False raw_log_file.close() log_file = open(output_file_path, 'w') for h in hashes: log_file.write(processed_data.get(h, '')) log_file.write('\n======================================================================================\n\n') log_file.close()