-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_status.py
More file actions
38 lines (28 loc) · 757 Bytes
/
git_status.py
File metadata and controls
38 lines (28 loc) · 757 Bytes
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
31
32
33
34
35
36
37
38
from i3pystatus import IntervalModule
from git import Repo
class GitStatus(IntervalModule):
"""
class fetches number of changed files from a specified local git
repository
Requires the PyPI package `GitPython`
..rubric:: Available formatters
* `{path}` - path to git repository
"""
format = ".dotfiles: {ch_files}"
settings = (
"path"
)
path = "~/.dotfiles"
def run(self):
repo = Repo(self.path)
index = repo.index.diff(None)
ch_files = len(index)
self.output = {
"full_text": self.format.format(ch_files=ch_files)
}
def main():
gs = GitStatus()
gs.run()
if __name__ == "__main__":
# execute only if run as a script
main()