dfsync 0.4.8__tar.gz → 0.4.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dfsync
3
- Version: 0.4.8
3
+ Version: 0.4.9
4
4
  Summary:
5
5
  Author: Mihai Balint
6
6
  Author-email: balint.mihai@gmail.com
@@ -1,4 +1,5 @@
1
- import black, fnmatch
1
+ import black
2
+ import fnmatch
2
3
  import os.path
3
4
  import git.exc
4
5
  import subprocess
@@ -111,6 +112,10 @@ class UntrackedGitFilesFilter(LoggingFilter):
111
112
  self._repos = {}
112
113
  self._is_repo_initialized = {}
113
114
  self._untracked_and_ignored_files = {}
115
+ self._should_filter_untracked_files = True
116
+
117
+ def set_should_filter_untracked_files(self, should_filter_untracked_files: bool = True):
118
+ self._should_filter_untracked_files = should_filter_untracked_files
114
119
 
115
120
  def get_untracked_and_ignored_files(self):
116
121
  flat_files = []
@@ -175,13 +180,17 @@ class UntrackedGitFilesFilter(LoggingFilter):
175
180
  self._ignore(src_file_path, "GIT repo internals")
176
181
  return True
177
182
 
178
- for rel_file_path in repo.untracked_files:
179
- abs_file_path = os.path.join(repo.working_dir, rel_file_path)
180
- if src_abs_path == abs_file_path:
181
- self._ignore(src_file_path, "Untracked GIT file")
182
- return True
183
+ if self._should_filter_untracked_files and self._is_untracked_file(repo, src_abs_path):
184
+ self._ignore(src_file_path, "Untracked GIT file")
185
+ return True
186
+
183
187
  return False
184
188
 
189
+ def _is_untracked_file(self, repo, src_abs_path):
190
+ return any(
191
+ src_abs_path == os.path.join(repo.working_dir, rel_file_path) for rel_file_path in repo.untracked_files
192
+ )
193
+
185
194
 
186
195
  USER_FILTERS = [EmacsBufferFilter(), PythonBlackFilter()]
187
196
  GIT_FILTER = UntrackedGitFilesFilter()
@@ -215,3 +224,7 @@ def add_user_filter(f: LoggingFilter):
215
224
 
216
225
  def add_user_ignored_patterns_filter(patterns: [str]):
217
226
  add_user_filter(UserConfigFilter(patterns))
227
+
228
+
229
+ def set_ignore_untracked_files(should_ignore_untracked_files: bool):
230
+ GIT_FILTER.set_should_filter_untracked_files(should_ignore_untracked_files)
@@ -12,6 +12,7 @@ from functools import partial
12
12
  from watchdog.observers import Observer
13
13
  from watchdog.events import FileSystemEventHandler
14
14
 
15
+ import dfsync.filters as filters
15
16
  from dfsync.backends import rsync_backend, kube_backend
16
17
  from dfsync.distribution import (
17
18
  get_installed_version,
@@ -21,7 +22,6 @@ from dfsync.distribution import (
21
22
  is_installed_in_editable_mode,
22
23
  update_package,
23
24
  )
24
- from dfsync.filters import add_user_ignored_patterns_filter, ALL_FILTERS
25
25
  from dfsync.config import read_config
26
26
  from dfsync.char_ui import KeyController
27
27
  from dfsync.kube_credentials import contextualize_kube_credentials, update_local_kube_config, normalized_k8s_url
@@ -54,7 +54,7 @@ class FileChangedEventHandler(ControlledThreadedOperation, FileSystemEventHandle
54
54
  **kwargs,
55
55
  ):
56
56
  super().__init__()
57
- self.filters = [*ALL_FILTERS]
57
+ self.filters = [*filters.ALL_FILTERS]
58
58
 
59
59
  self.backend = backend
60
60
  self.backend_options = kwargs
@@ -263,6 +263,10 @@ def version():
263
263
  """
264
264
  Print the currently installed version
265
265
  """
266
+ _version()
267
+
268
+
269
+ def _version():
266
270
  installed_version = get_installed_version()
267
271
  click.echo(f"{installed_version}")
268
272
 
@@ -275,6 +279,16 @@ def version():
275
279
  click.echo(f"Latest version is {latest_version}, please update using `dfsync self-update`")
276
280
 
277
281
 
282
+ @main.command(name="help", context_settings=dict(ignore_unknown_options=True))
283
+ @click.option("--help", is_flag=True, default=False, hidden=True)
284
+ def help(help):
285
+ """
286
+ Print the usage/help for dfsync
287
+ """
288
+ with click.Context(sync, info_name="dfsync") as ctx:
289
+ click.echo(sync.get_help(ctx))
290
+
291
+
278
292
  @main.command()
279
293
  def self_update():
280
294
  """
@@ -309,11 +323,15 @@ def import_kube_host(kube_host=None, credentials=None):
309
323
  @main.command()
310
324
  @click.argument("source", nargs=-1)
311
325
  @click.argument("destination", default="", nargs=1)
312
- @click.option("--supervisor/--no-supervisor", default=False, help="Try to install supervisor in container", type=bool)
326
+ @click.option("--supervisor", is_flag=True, default=False, help="Try to install supervisor in container")
313
327
  @click.option("--kube-host", default=None, help="Kubernetes api host server address/hostname", type=str)
314
328
  @click.option("--pod-timeout", default=30, help="Pod reconfiguration timeout (default is 30 seconds)", type=int)
315
329
  @click.option("--full-sync/--no-full-sync", default=True, help="On startup, sync all files to destination", type=bool)
316
- def sync(source, destination, supervisor, kube_host, pod_timeout, full_sync):
330
+ @click.option("--version", is_flag=True, default=False, help="Print the currently installed version")
331
+ @click.option(
332
+ "--sync-git-untracked", is_flag=True, default=False, help="Sync git-untracked files instead of ignoring them"
333
+ )
334
+ def sync(source, destination, supervisor, kube_host, pod_timeout, full_sync, version, sync_git_untracked):
317
335
  """
318
336
  Watches a folder for changes and propagates all file changes to a destination.
319
337
 
@@ -353,7 +371,14 @@ def sync(source, destination, supervisor, kube_host, pod_timeout, full_sync):
353
371
 
354
372
  paths = ["."] if len(source) == 0 else source
355
373
  config = read_config(destination, *paths)
356
- add_user_ignored_patterns_filter(config.ignore_files)
374
+ filters.add_user_ignored_patterns_filter(config.ignore_files)
375
+
376
+ if sync_git_untracked:
377
+ filters.set_ignore_untracked_files(False)
378
+
379
+ if version:
380
+ _version()
381
+ return
357
382
 
358
383
  destination_dir = destination
359
384
  if len(source) == 0 and config.destination and not has_destination_optics(destination):
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dfsync"
3
- version = "0.4.8"
3
+ version = "0.4.9"
4
4
  description = ""
5
5
  authors = ["Mihai Balint <balint.mihai@gmail.com>"]
6
6
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes