Last active
November 21, 2018 03:32
-
-
Save Benhgift/1a33bca248c983286ee89cd6b8a9545c to your computer and use it in GitHub Desktop.
open some changed files on branch, compared to master
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 characters
#!/usr/bin/env python3 | |
from subprocess import getoutput | |
import os | |
import re | |
def main(): | |
files = get_files() | |
if not files[0]: return error() | |
nums = file_nums_to_open(files) | |
file_dict = get_file_dict(files) | |
for num in nums: | |
os.system('gvim ' + file_dict[num]) | |
def error(): | |
print('no files changed on this branch') | |
def get_files(): | |
return getoutput('git diff master --name-only').split('\n') | |
def file_nums_to_open(files): | |
print_files(files) | |
nums = input('\ntype file numbers to open\n') | |
return map(int, re.findall(r'\d+', nums)) | |
def print_files(files): | |
for i, f in enumerate(files): | |
if i < 10: | |
print(i, '', f) | |
else: | |
print(i, f) | |
def get_file_dict(files): | |
return { i: f for i, f in enumerate(files) } | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment