| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -513,35 +513,33 @@ def is_dirty(self, index=True, working_tree=True, untracked_files=False): | |||
| 513 | 513 | return True | |
| 514 | 514 | # END untracked files | |
| 515 | 515 | return False | |
| 516 | - | ||
| 516 | + | ||
| 517 | 517 | @property | |
| 518 | 518 | def untracked_files(self): | |
| 519 | 519 | """ | |
| 520 | 520 | :return: | |
| 521 | 521 | list(str,...) | |
| 522 | - | ||
| 523 | - Files currently untracked as they have not been staged yet. Paths | ||
| 522 | + | ||
| 523 | + Files currently untracked as they have not been staged yet. Paths | ||
| 524 | 524 | are relative to the current working directory of the git command. | |
| 525 | - | ||
| 525 | + | ||
| 526 | 526 | :note: | |
| 527 | 527 | ignored files will not appear here, i.e. files mentioned in .gitignore""" | |
| 528 | 528 | # make sure we get all files, no only untracked directores | |
| 529 | - proc = self.git.status(untracked_files=True, as_process=True) | ||
| 530 | - stream = iter(proc.stdout) | ||
| 529 | + proc = self.git.status(porcelain=True, | ||
| 530 | + untracked_files=True, | ||
| 531 | + as_process=True) | ||
| 532 | + # Untracked files preffix in porcelain mode | ||
| 533 | + prefix = "?? " | ||
| 531 | 534 | untracked_files = list() | |
| 532 | - for line in stream: | ||
| 533 | - if not line.startswith("# Untracked files:"): | ||
| 535 | + for line in proc.stdout: | ||
| 536 | + if not line.startswith(prefix): | ||
| 534 | 537 | continue | |
| 535 | - # skip two lines | ||
| 536 | - stream.next() | ||
| 537 | - stream.next() | ||
| 538 | - | ||
| 539 | - for untracked_info in stream: | ||
| 540 | - if not untracked_info.startswith("#\t"): | ||
| 541 | - break | ||
| 542 | - untracked_files.append(untracked_info.replace("#\t", "").rstrip()) | ||
| 543 | - # END for each utracked info line | ||
| 544 | - # END for each line | ||
| 538 | + filename = line[len(preffix):].rstrip('\n') | ||
| 539 | + # Special characters are escaped | ||
| 540 | + if filename[0] == filename[-1] == '"': | ||
| 541 | + filename = filename[1:-1].decode('string_escape') | ||
| 542 | + untracked_files.append(filename) | ||
| 545 | 543 | return untracked_files | |
| 546 | 544 | ||
| 547 | 545 | @property | |
| Back | FazBrowse Home | New Git URL |
0 commit comments