Skip to content

Commit

Permalink
added fullpath to fix path concat issue with files when not in git ro…
Browse files Browse the repository at this point in the history
…ot (pantsbuild#6331)

### Problem
As described in pantsbuild#6301 , when the git root and the build root is not the same, `changed` functionalities can be messed up because `git` returns path relative to the working directory, which produces bad paths when it is [concatenated with the git root](https://github.com/pantsbuild/pants/blob/c9f3af460a7504e082931a4b5a668b66f0cd4ed0/src/python/pants/scm/git.py#L161).

### Solution
By adding the `--full-name` tag to [`git ls-files`](https://github.com/pantsbuild/pants/blob/c9f3af460a7504e082931a4b5a668b66f0cd4ed0/src/python/pants/scm/git.py#L178), the file concatenation is done properly

### Result
Doing `./pants list --changed...` will concatenate file names correctly when it is not run from the git root.
  • Loading branch information
yaup authored and Stu Hood committed Aug 12, 2018
1 parent c329660 commit 20d267f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/python/pants/scm/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def changed_files(self, from_commit=None, include_untracked=False, relative_to=N
raise_type=Scm.LocalException)
files.update(committed_changes.split())
if include_untracked:
untracked_cmd = ['ls-files', '--other', '--exclude-standard'] + rel_suffix
untracked_cmd = ['ls-files', '--other', '--exclude-standard', '--full-name'] + rel_suffix
untracked = self._check_output(untracked_cmd,
raise_type=Scm.LocalException)
files.update(untracked.split())
Expand Down

0 comments on commit 20d267f

Please sign in to comment.