-
Notifications
You must be signed in to change notification settings - Fork 0
/
gitDir.py
31 lines (26 loc) · 878 Bytes
/
gitDir.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2019 mursalin <[email protected]>
#
# Distributed under terms of the MIT license.
import os
import sys
class GitDir:
def __init__(self, path):
self.dir = path
self.untracked = self.get_untracked()
self.modified = self.get_modified()
def get_untracked(self):
cmd = "cd "+self.dir+" && git ls-files --others --exclude-standard"
output = os.popen(cmd).read().split('\n')
output.remove('')
output[:] = [os.path.join(self.dir,x) for x in output]
return output
def get_modified(self):
cmd = "cd "+self.dir+" && git status -s | grep '^ M'"
output = os.popen(cmd).read().split(' M ')
output.remove('')
output[:] = [os.path.join(self.dir,x.replace('\n','')) for x in output]
return output