Skip to content

Commit 14f5207

Browse files
author
Greg Soltis
authored
fix(Turborepo): Handle spaces in path names in git status (#7197)
### Description - Don't stop `git status` parsing when encountering a space ### Testing Instructions - Added a unit test for `git status` testing - Added an integration test for a dry run with an added file with a space in the path name Closes TURBO-2209 --------- Co-authored-by: Greg Soltis <Greg Soltis>
1 parent 7351651 commit 14f5207

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

crates/turborepo-scm/src/status.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn nom_parse_status(i: &[u8]) -> nom::IResult<&[u8], StatusEntry<'_>> {
9191
let (i, x) = nom::bytes::complete::take(1usize)(i)?;
9292
let (i, y) = nom::bytes::complete::take(1usize)(i)?;
9393
let (i, _) = nom::character::complete::space1(i)?;
94-
let (i, filename) = nom::bytes::complete::is_not(" \0")(i)?;
94+
let (i, filename) = nom::bytes::complete::is_not("\0")(i)?;
9595
// We explicitly support a missing terminator
9696
let (i, _) = nom::combinator::opt(nom::bytes::complete::tag(&[b'\0']))(i)?;
9797
Ok((
@@ -125,6 +125,11 @@ mod tests {
125125
),
126126
("M package.json\0", "", ("package.json", false)),
127127
("A some-pkg/some-file\0", "some-pkg", ("some-file", false)),
128+
(
129+
"M some-pkg/file with spaces\0",
130+
"some-pkg",
131+
("file with spaces", false),
132+
),
128133
];
129134
for (input, prefix, (expected_filename, expect_delete)) in tests {
130135
let prefix = RelativeUnixPathBuf::new(*prefix).unwrap();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Setup
2+
$ . ${TESTDIR}/../../../helpers/setup_integration_test.sh
3+
4+
Force git status to show a file with spaces in the name
5+
$ echo "new file" > packages/util/with\ spaces.txt
6+
7+
Verify we have a file with spaces in the name
8+
$ git status | grep -q "with spaces"
9+
10+
Do a dry run to verify we can hash it
11+
$ ${TURBO} run build --dry -F util | grep "Inputs Files Considered"
12+
Inputs Files Considered = 2

0 commit comments

Comments
 (0)