3 from git_python
import Git
7 def stagedChanges(ignoreAddedFiles
=False):
8 """Returns the paths to all files that have changes staged.
9 When calling this function the current directory should be the root
10 of the git directory that should be acted on.
13 ignoreAddedFiles: When True files that added newly are ignored.
16 A list of paths that were changed.
20 result
= git
.diff_index("--cached", "--name-status", "HEAD")
22 log
= result
.split('\n')
27 # Skip the last empty line
28 if len(line
.lstrip()) == 0:
31 splitline
= line
.split('\t')
33 # Skip files that were freshly added
34 if splitline
[0] == 'A' and ignoreAddedFiles
:
37 changed
.append(splitline
[1])
42 """Shows what commits touched the same files as the currently staged changes.
45 staged
= stagedChanges(True)
47 print("No changes staged (or only new files added)")
50 touched
= commit
.commitsThatTouched(staged
)
51 commit
.prettyPrint(touched
)
56 if __name__
== '__main__':
60 staged
= stagedChanges(True)
63 print("No changes staged (or only new files added)")