4
4
from typing import TYPE_CHECKING , Any , TypedDict , Union
5
5
6
6
from dvc .fs .callbacks import DEFAULT_CALLBACK
7
+ from dvc .log import logger
7
8
from dvc .ui import ui
8
9
10
+ logger = logger .getChild (__name__ )
11
+
9
12
if TYPE_CHECKING :
10
13
from dvc .fs .callbacks import Callback
11
14
from dvc .repo import Repo
@@ -217,7 +220,29 @@ def _transform_git_paths_to_dvc(repo: "Repo", files: Iterable[str]) -> list[str]
217
220
return [repo .fs .relpath (file , start ) for file in files ]
218
221
219
222
220
- def status (repo : "Repo" , untracked_files : str = "no" , ** kwargs : Any ) -> Status :
223
+ def _filter_out_push_false_outs (repo : "Repo" , not_in_remote : list [str ]) -> list [str ]:
224
+ """Filter out paths that are not pushable."""
225
+ filtered_not_in_remote = []
226
+
227
+ for path in not_in_remote :
228
+ (out ,) = repo .find_outs_by_path (path )
229
+
230
+ if out .can_push :
231
+ filtered_not_in_remote .append (path )
232
+ else :
233
+ logger .trace (
234
+ f"Eliminating { path } from not_in_remote, because it is not pushable"
235
+ )
236
+
237
+ return filtered_not_in_remote
238
+
239
+
240
+ def status (
241
+ repo : "Repo" ,
242
+ untracked_files : str = "no" ,
243
+ respect_no_push : bool = False ,
244
+ ** kwargs : Any ,
245
+ ) -> Status :
221
246
from dvc .scm import NoSCMError , SCMError
222
247
223
248
head = kwargs .pop ("head" , "HEAD" )
@@ -234,10 +259,17 @@ def status(repo: "Repo", untracked_files: str = "no", **kwargs: Any) -> Status:
234
259
git_info = _git_info (repo .scm , untracked_files = untracked_files )
235
260
untracked = git_info .get ("untracked" , [])
236
261
untracked = _transform_git_paths_to_dvc (repo , untracked )
262
+
263
+ not_in_remote = uncommitted_diff .pop ("not_in_remote" , [])
264
+
265
+ if respect_no_push :
266
+ logger .debug ("Filtering out paths that are not pushable" )
267
+ not_in_remote = _filter_out_push_false_outs (repo , not_in_remote )
268
+
237
269
# order matters here
238
270
return Status (
239
271
not_in_cache = uncommitted_diff .pop ("not_in_cache" , []),
240
- not_in_remote = uncommitted_diff . pop ( " not_in_remote" , []) ,
272
+ not_in_remote = not_in_remote ,
241
273
committed = committed_diff ,
242
274
uncommitted = uncommitted_diff ,
243
275
untracked = untracked ,
0 commit comments