dotctl 1.0.6__tar.gz → 1.0.7__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.
Files changed (41) hide show
  1. {dotctl-1.0.6/src/dotctl.egg-info → dotctl-1.0.7}/PKG-INFO +1 -1
  2. {dotctl-1.0.6 → dotctl-1.0.7}/pyproject.toml +1 -1
  3. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/activator.py +6 -1
  4. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/initializer.py +11 -6
  5. dotctl-1.0.7/src/dotctl/actions/puller.py +34 -0
  6. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/saver.py +4 -1
  7. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/arg_manager.py +5 -0
  8. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/handlers/config_handler.py +2 -2
  9. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/handlers/git_handler.py +26 -0
  10. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/handlers/hooks_handler.py +12 -2
  11. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/main.py +7 -0
  12. {dotctl-1.0.6 → dotctl-1.0.7/src/dotctl.egg-info}/PKG-INFO +1 -1
  13. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl.egg-info/SOURCES.txt +1 -0
  14. {dotctl-1.0.6 → dotctl-1.0.7}/LICENSE +0 -0
  15. {dotctl-1.0.6 → dotctl-1.0.7}/README.md +0 -0
  16. {dotctl-1.0.6 → dotctl-1.0.7}/setup.cfg +0 -0
  17. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/__init__.py +0 -0
  18. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/__init__.py +0 -0
  19. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/creator.py +0 -0
  20. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/exporter.py +0 -0
  21. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/importer.py +0 -0
  22. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/lister.py +0 -0
  23. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/remover.py +0 -0
  24. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/switcher.py +0 -0
  25. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/actions/wiper.py +0 -0
  26. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/exception.py +0 -0
  27. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/handlers/__init__.py +0 -0
  28. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/handlers/data_handler.py +0 -0
  29. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/hooks/post_apply.sh +0 -0
  30. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/hooks/pre_apply.sh +0 -0
  31. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/paths.py +0 -0
  32. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/templates/__init__.py +0 -0
  33. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/templates/dev.yaml +0 -0
  34. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/templates/kde.yaml +0 -0
  35. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/templates/other.yaml +0 -0
  36. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/utils.py +0 -0
  37. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl/validators.py +0 -0
  38. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl.egg-info/dependency_links.txt +0 -0
  39. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl.egg-info/entry_points.txt +0 -0
  40. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl.egg-info/requires.txt +0 -0
  41. {dotctl-1.0.6 → dotctl-1.0.7}/src/dotctl.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotctl
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
5
5
  Author-email: Pankaj Jackson <pankajackson@live.co.uk>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dotctl"
7
- version = "v1.0.6"
7
+ version = "v1.0.7"
8
8
  description = "A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -10,6 +10,7 @@ from dotctl.handlers.git_handler import (
10
10
  get_repo_branches,
11
11
  git_fetch,
12
12
  checkout_branch,
13
+ pull_changes,
13
14
  )
14
15
  from dotctl.exception import exception_handler
15
16
 
@@ -57,6 +58,10 @@ def apply(props: ActivatorProps) -> None:
57
58
  return
58
59
 
59
60
  config = conf_reader(config_file=Path(app_config_file))
61
+
62
+ if pull_changes(repo):
63
+ log("✅ Pulled latest changes from cloud successfully.")
64
+
60
65
  if not props.skip_hooks and not props.skip_pre_hooks:
61
66
  run_hooks(
62
67
  pre_apply_hooks=True,
@@ -90,4 +95,4 @@ def apply(props: ActivatorProps) -> None:
90
95
  ignore_errors=props.ignore_hook_errors,
91
96
  timeout=props.hooks_timeout,
92
97
  )
93
- log("Profile saved successfully!")
98
+ log("✅ Profile saved successfully!")
@@ -66,16 +66,21 @@ def initialise(props: InitializerProps):
66
66
  raise Exception(f"Failed to initialize profile repo at {props.dest}. ")
67
67
  if props.profile:
68
68
  checkout_branch(repo, props.profile)
69
+ log(f"Switching to Profile `{props.profile}`.")
69
70
 
70
71
  if props.config is not None and isinstance(props.config, str):
71
72
  props.config = Path(props.config)
72
73
 
73
- conf_initializer(
74
- env=props.env,
75
- custom_config=props.config,
76
- )
77
- hooks_initializer()
74
+ initialized_config = conf_initializer(env=props.env, custom_config=props.config)
75
+ if initialized_config is not None:
76
+ log(f"Config initialized successfully.")
77
+
78
+ initialized_hooks = hooks_initializer()
79
+ if initialized_hooks:
80
+ log(f"Hooks initialized successfully {initialized_hooks}.")
81
+
78
82
  add_changes(repo=repo)
83
+
79
84
  if is_repo_changed(repo=repo):
80
85
  hostname = socket.gethostname()
81
86
  timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
@@ -94,4 +99,4 @@ def initialise(props: InitializerProps):
94
99
  else:
95
100
  push_existing_branch(repo=repo)
96
101
 
97
- log("Profile initialized successfully.")
102
+ log("✅ Profile initialized successfully.")
@@ -0,0 +1,34 @@
1
+ import shutil
2
+ from pathlib import Path
3
+ from datetime import datetime
4
+ from dataclasses import dataclass
5
+ from dotctl.paths import app_profile_directory
6
+ from dotctl.utils import log
7
+ from dotctl.exception import exception_handler
8
+ from dotctl.handlers.git_handler import get_repo, pull_changes
9
+ from dotctl import __APP_NAME__, __DEFAULT_PROFILE__
10
+
11
+
12
+ @dataclass
13
+ class PullerProps:
14
+ profile_dir: Path
15
+
16
+
17
+ puller_default_props = PullerProps(
18
+ profile_dir=Path(app_profile_directory),
19
+ )
20
+
21
+
22
+ @exception_handler
23
+ def pull(props: PullerProps):
24
+ log("Pulling profile changes...")
25
+ repo = get_repo(props.profile_dir)
26
+ try:
27
+ changes = pull_changes(repo)
28
+ if changes is None:
29
+ log("✅ Profile already up to date.")
30
+ elif changes:
31
+ log("✅ Pulled latest changes successfully.")
32
+
33
+ except Exception as e:
34
+ raise Exception(f"Unexpected error: {e}")
@@ -10,6 +10,7 @@ from dotctl.handlers.git_handler import (
10
10
  get_repo,
11
11
  get_repo_branches,
12
12
  git_fetch,
13
+ pull_changes,
13
14
  checkout_branch,
14
15
  create_branch,
15
16
  is_repo_changed,
@@ -54,6 +55,8 @@ def save(props: SaverProps) -> None:
54
55
  else:
55
56
  create_branch(repo=repo, branch=profile)
56
57
  log(f"Profile '{profile}' created and activated successfully.")
58
+ if pull_changes(repo):
59
+ log("✅ Pulled latest changes from cloud successfully.")
57
60
 
58
61
  config = conf_reader(config_file=Path(app_config_file))
59
62
 
@@ -92,6 +95,6 @@ def save(props: SaverProps) -> None:
92
95
  push_new_branch(repo=repo)
93
96
  else:
94
97
  push_existing_branch(repo=repo)
95
- log("Profile saved successfully!")
98
+ log("✅ Profile saved successfully!")
96
99
  else:
97
100
  log("No changes detected!")
@@ -274,6 +274,11 @@ def get_parser() -> argparse.ArgumentParser:
274
274
  action="store_true",
275
275
  help="Skip all sudo operations",
276
276
  )
277
+ # Pull Parser
278
+ pull_parser = subparsers.add_parser(
279
+ "pull", help="Pull the latest changes from the dotfiles repository"
280
+ )
281
+
277
282
  # Wipe Parser
278
283
  wipe_parser = subparsers.add_parser("wipe", help="Wipe Profiles")
279
284
 
@@ -91,10 +91,10 @@ def conf_initializer(
91
91
  env: str | None = None,
92
92
  custom_config: Path | None = None,
93
93
  app_config_file_path: Path = Path(app_config_file),
94
- ) -> Path:
94
+ ) -> Path | None:
95
95
 
96
96
  if app_config_file_path.exists():
97
- return app_config_file_path
97
+ return None
98
98
 
99
99
  if custom_config:
100
100
  log(f"Using custom config file: {custom_config}")
@@ -226,6 +226,32 @@ def push_new_branch(repo: Repo) -> None:
226
226
  )
227
227
 
228
228
 
229
+ def pull_changes(repo: Repo) -> bool | None:
230
+ is_remote, origin = is_remote_repo(repo)
231
+ if not is_remote or origin is None:
232
+ log("Warning: Skipping pull. This is not a remote repository.")
233
+ return None
234
+
235
+ if repo.bare:
236
+ raise Exception("Error: The repository is bare. Cannot pull changes.")
237
+
238
+ git_fetch(repo)
239
+
240
+ current_branch = repo.active_branch.name
241
+ local_commit = repo.commit(current_branch)
242
+ remote_commit = repo.commit(f"origin/{current_branch}")
243
+
244
+ if local_commit.hexsha == remote_commit.hexsha:
245
+ return None
246
+
247
+ log("📥 Update found:")
248
+ for commit in repo.iter_commits(f"{current_branch}..origin/{current_branch}"):
249
+ log(f" - {commit.summary} ({commit.hexsha[:7]})")
250
+
251
+ origin.pull()
252
+ return True
253
+
254
+
229
255
  def get_repo_meta(repo: Repo) -> RepoMetaData:
230
256
 
231
257
  if repo.bare:
@@ -7,10 +7,20 @@ from dotctl.utils import log, new_line
7
7
  from .data_handler import copy
8
8
 
9
9
 
10
- def hooks_initializer(app_hooks_dir_path: Path = Path(app_hooks_directory)):
10
+ def hooks_initializer(
11
+ app_hooks_dir_path: Path = Path(app_hooks_directory),
12
+ ) -> list[Path]:
11
13
  app_hooks_dir_path.mkdir(parents=True, exist_ok=True)
12
14
  hooks_base_dir = Path(__BASE_DIR__) / "hooks"
13
- copy(hooks_base_dir, app_hooks_dir_path)
15
+
16
+ initialized_hooks = []
17
+ for hook_file in hooks_base_dir.iterdir():
18
+ target_file = app_hooks_dir_path / hook_file.name
19
+ if not target_file.exists():
20
+ copy(hook_file, target_file)
21
+ initialized_hooks.append(hook_file.name)
22
+
23
+ return initialized_hooks
14
24
 
15
25
 
16
26
  def run_shell_script(
@@ -9,6 +9,7 @@ from .actions.saver import save, saver_default_props
9
9
  from .actions.activator import apply, activator_default_props
10
10
  from .actions.lister import get_profile_list, lister_default_props
11
11
  from .actions.switcher import switch, switcher_default_props
12
+ from .actions.puller import pull, puller_default_props
12
13
  from .actions.creator import create, creator_default_props
13
14
  from .actions.remover import remove, remover_default_props
14
15
  from .actions.exporter import exporter, exporter_default_props
@@ -22,6 +23,7 @@ class Action(Enum):
22
23
  LS = "ls"
23
24
  SWITCH = "switch"
24
25
  SW = "sw"
26
+ PULL = "pull"
25
27
  SAVE = "save"
26
28
  APPLY = "apply"
27
29
  CREATE = "create"
@@ -52,6 +54,7 @@ class DotCtl:
52
54
  Action.LS: self.list_profiles,
53
55
  Action.SWITCH: self.switch_profile,
54
56
  Action.SW: self.switch_profile,
57
+ Action.PULL: self.pull_profile,
55
58
  Action.CREATE: self.create_profile,
56
59
  Action.NEW: self.create_profile,
57
60
  Action.REMOVE: self.remove_profile,
@@ -141,6 +144,10 @@ class DotCtl:
141
144
  props = self._build_props(wiper_default_props, "no_confirm")
142
145
  wipe(props)
143
146
 
147
+ def pull_profile(self):
148
+ """Pull dotfiles profile."""
149
+ pull(puller_default_props)
150
+
144
151
 
145
152
  @exception_handler
146
153
  def main():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dotctl
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: A powerful CLI tool to profile your OS by saving, applying, exporting, and importing system configurations as named profiles. Designed to manage dot files and service configurations in a centralized Git repository (local or remote), dotctl enables seamless system replication across machines. Supports pre/post hook scripts, making it ideal for setting up servers or desktops with consistent environments.
5
5
  Author-email: Pankaj Jackson <pankajackson@live.co.uk>
6
6
  License-Expression: MIT
@@ -21,6 +21,7 @@ src/dotctl/actions/exporter.py
21
21
  src/dotctl/actions/importer.py
22
22
  src/dotctl/actions/initializer.py
23
23
  src/dotctl/actions/lister.py
24
+ src/dotctl/actions/puller.py
24
25
  src/dotctl/actions/remover.py
25
26
  src/dotctl/actions/saver.py
26
27
  src/dotctl/actions/switcher.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes