| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
__license__ = 'GPL v3' |
| 4 |
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>' |
| 5 |
|
| 6 |
import os |
| 7 |
import runpy |
| 8 |
import subprocess |
| 9 |
import sys |
| 10 |
|
| 11 |
prev_rev, current_rev, flags = sys.argv[1:] |
| 12 |
|
| 13 |
|
| 14 |
def get_branch_name(rev): |
| 15 |
return subprocess.check_output(['git', 'name-rev', '--name-only', '--refs=refs/heads/*', rev]).decode('utf-8').strip() |
| 16 |
|
| 17 |
|
| 18 |
base = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
| 19 |
os.chdir(base) |
| 20 |
|
| 21 |
if flags == '1': # A branch checkout |
| 22 |
prev_branch, cur_branch = list(map(get_branch_name, (prev_rev, current_rev))) |
| 23 |
rebase_in_progress = os.path.exists('.git/rebase-apply') or os.path.exists('.git/rebase-merge') |
| 24 |
|
| 25 |
before = sys.argv |
| 26 |
try: |
| 27 |
sys.argv = ['setup.py', 'gui', '--summary'] |
| 28 |
runpy.run_path('setup.py', run_name='__main__') |
| 29 |
finally: |
| 30 |
sys.argv = before |
| 31 |
|
| 32 |
# Remove .pyc files as some of them might have been orphaned |
| 33 |
for dirpath, dirnames, filenames in os.walk('.'): |
| 34 |
for f in filenames: |
| 35 |
fpath = os.path.join(dirpath, f) |
| 36 |
if f.endswith('.pyc') and '/chroot/' not in fpath: |
| 37 |
os.remove(fpath) |