Stop tracking changes to path.
(self, path)
| 835 | raise GlError('File {0} in unknown status {1}'.format(path, git_st)) |
| 836 | |
| 837 | def untrack_file(self, path): |
| 838 | """Stop tracking changes to path.""" |
| 839 | _check_path_is_repo_relative(path) |
| 840 | |
| 841 | gl_st, git_st, is_au = self._status_file(path) |
| 842 | |
| 843 | if gl_st.type == GL_STATUS_UNTRACKED: |
| 844 | raise ValueError('File {0} is already untracked'.format(path)) |
| 845 | elif gl_st.type == GL_STATUS_IGNORED: |
| 846 | raise ValueError( |
| 847 | 'File {0} is ignored. Edit the .gitignore file to stop ignoring ' |
| 848 | 'file {0}'.format(path)) |
| 849 | elif gl_st.in_conflict: |
| 850 | raise ValueError('File {0} has conflicts'.format(path)) |
| 851 | |
| 852 | # If we reached this point we know that the file to untrack is a tracked |
| 853 | # file. This means that in the Git world, the file could be either: |
| 854 | # (i) a new file for Git that is staged (the user executed `gl track` on |
| 855 | # an uncommitted file) => reset changes; |
| 856 | # (ii) the file is a previously committed file => mark it as assumed |
| 857 | # unchanged. |
| 858 | if git_st == pygit2.GIT_STATUS_INDEX_NEW: # Case (i) |
| 859 | with self._index as index: |
| 860 | git_path = _get_git_path(path) |
| 861 | index.remove(git_path) |
| 862 | elif not is_au: # Case (ii) |
| 863 | git('update-index', '--assume-unchanged', path, |
| 864 | _cwd=self.gl_repo.root) |
| 865 | else: |
| 866 | raise GlError('File {0} in unknown status {1}'.format(path, git_st)) |
| 867 | |
| 868 | def resolve_file(self, path): |
| 869 | """Mark the given path as resolved.""" |