8000 fix(git): Fix update_repo when there are untracked files · vcs-python/libvcs@caf47b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit caf47b5

Browse files
committed
fix(git): Fix update_repo when there are untracked files
1 parent ff9247b commit caf47b5

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

libvcs/projects/git.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,9 @@ def update_repo(self, set_remotes: bool = False, *args, **kwargs):
435435
# to be able to perform git pull --rebase
436436
if need_stash:
437437
# If Git < 1.7.6, uses --quiet --all
438-
git_stash_save_options = "--quiet"
438+
git_stash_save_options = ["--quiet", "--include-untracked"]
439439
try:
440-
process = self.run(["stash", "save", git_stash_save_options])
440+
process = self.run(["stash", "save"] + git_stash_save_options)
441441
except exc.CommandError:
442442
self.log.error("Failed to stash changes")
443443

tests/projects/test_git.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,39 @@ def test_repo_git_obtain_full(
108108

109109
@pytest.mark.parametrize(
110110
# Postpone evaluation of options so fixture variables can interpolate
111-
"constructor,lazy_constructor_options",
111+
"constructor,lazy_constructor_options,has_untracked_files",
112112
[
113113
[
114114
GitProject,
115115
lambda git_remote_repo, tmp_path, **kwargs: {
116116
"url": f"file://{git_remote_repo}",
117117
"dir": tmp_path / "myrepo",
118118
},
119+
False
120+
],
121+
[
122+
GitProject,
123+
lambda git_remote_repo, tmp_path, **kwargs: {
124+
"url": f"file://{git_remote_repo}",
125+
"dir": tmp_path / "myrepo",
126+
},
127+
True
119128
],
120129
[
121130
create_project_from_pip_url,
122131
lambda git_remote_repo, tmp_path, **kwargs: {
123132
"pip_url": f"git+file://{git_remote_repo}",
124133
"dir": tmp_path / "myrepo",
125134
},
135+
False
136+
],
137+
[
138+
create_project_from_pip_url,
139+
lambda git_remote_repo, tmp_path, **kwargs: {
140+
"pip_url": f"git+file://{git_remote_repo}",
141+
"dir": tmp_path / "myrepo",
142+
},
143+
True
126144
],
127145
],
128146
)
@@ -132,9 +150,16 @@ def test_repo_update_handle_cases(
132150
mocker: MockerFixture,
133151
constructor: ProjectTestFactory,
134152
lazy_constructor_options: ProjectTestFactoryLazyKwargs,
153+
has_untracked_files: bool,
135154
):
136155
git_repo: GitProject = constructor(**lazy_constructor_options(**locals()))
137156
git_repo.obtain() # clone initial repo
157+
158+
if has_untracked_files:
159+
some_file = git_repo.dir.joinpath("some_file")
160+
with open(some_file, "w") as untracked_file:
161+
untracked_file.write("some content")
162+
138163
mocka = mocker.spy(git_repo, "run")
139164
git_repo.update_repo()
140165

0 commit comments

Comments
 (0)
0