dotctl 1.0.6__tar.gz → 1.0.8__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.
- {dotctl-1.0.6/src/dotctl.egg-info → dotctl-1.0.8}/PKG-INFO +1 -1
- {dotctl-1.0.6 → dotctl-1.0.8}/pyproject.toml +1 -1
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/activator.py +7 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/creator.py +2 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/exporter.py +2 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/importer.py +5 -5
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/initializer.py +12 -7
- dotctl-1.0.8/src/dotctl/actions/puller.py +34 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/remover.py +7 -7
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/saver.py +5 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/switcher.py +5 -5
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/wiper.py +4 -4
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/arg_manager.py +5 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/handlers/config_handler.py +2 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/handlers/git_handler.py +29 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/handlers/hooks_handler.py +12 -2
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/main.py +7 -0
- {dotctl-1.0.6 → dotctl-1.0.8/src/dotctl.egg-info}/PKG-INFO +1 -1
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl.egg-info/SOURCES.txt +1 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/LICENSE +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/README.md +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/setup.cfg +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/__init__.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/__init__.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/actions/lister.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/exception.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/handlers/__init__.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/handlers/data_handler.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/hooks/post_apply.sh +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/hooks/pre_apply.sh +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/paths.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/templates/__init__.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/templates/dev.yaml +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/templates/kde.yaml +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/templates/other.yaml +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/utils.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl/validators.py +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl.egg-info/dependency_links.txt +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl.egg-info/entry_points.txt +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/src/dotctl.egg-info/requires.txt +0 -0
- {dotctl-1.0.6 → dotctl-1.0.8}/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.
|
|
3
|
+
Version: 1.0.8
|
|
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.
|
|
7
|
+
version = "v1.0.8"
|
|
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
|
|
|
@@ -53,10 +54,14 @@ def apply(props: ActivatorProps) -> None:
|
|
|
53
54
|
checkout_branch(repo, profile)
|
|
54
55
|
log(f"Switched to profile: {profile}")
|
|
55
56
|
else:
|
|
56
|
-
log(f"Profile {profile} is not available.")
|
|
57
|
+
log(f"❌ Profile {profile} is not available.")
|
|
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
|
|
98
|
+
log("✅ Profile applied successfully!")
|
|
@@ -53,7 +53,7 @@ def create(props: CreatorProps):
|
|
|
53
53
|
|
|
54
54
|
_, _, _, all_profiles = get_repo_branches(repo)
|
|
55
55
|
if props.profile in all_profiles:
|
|
56
|
-
log(f"Profile '{props.profile}' already exists.")
|
|
56
|
+
log(f"❌ Profile '{props.profile}' already exists.")
|
|
57
57
|
return
|
|
58
58
|
if props.env or props.config:
|
|
59
59
|
if props.config is not None and isinstance(props.config, str):
|
|
@@ -86,4 +86,4 @@ def create(props: CreatorProps):
|
|
|
86
86
|
else:
|
|
87
87
|
push_existing_branch(repo=repo)
|
|
88
88
|
|
|
89
|
-
log(f"Profile '{props.profile}' created and activated successfully.")
|
|
89
|
+
log(f"✅ Profile '{props.profile}' created and activated successfully.")
|
|
@@ -67,7 +67,7 @@ def exporter(props: ExporterProps) -> None:
|
|
|
67
67
|
checkout_branch(repo, profile)
|
|
68
68
|
log(f"Switched to profile: {profile}")
|
|
69
69
|
else:
|
|
70
|
-
log(f"Profile '{profile}' not found.")
|
|
70
|
+
log(f"❌ Profile '{profile}' not found.")
|
|
71
71
|
return
|
|
72
72
|
|
|
73
73
|
# Copy profile files
|
|
@@ -117,7 +117,7 @@ def exporter(props: ExporterProps) -> None:
|
|
|
117
117
|
shutil.move(archive_file, export_profile_path.with_suffix(__EXPORT_EXTENSION__))
|
|
118
118
|
|
|
119
119
|
log(
|
|
120
|
-
f"Successfully exported to {export_profile_path.with_suffix(__EXPORT_EXTENSION__)}"
|
|
120
|
+
f"✅ Successfully exported to {export_profile_path.with_suffix(__EXPORT_EXTENSION__)}"
|
|
121
121
|
)
|
|
122
122
|
finally:
|
|
123
123
|
shutil.rmtree(export_profile_path, ignore_errors=True)
|
|
@@ -40,17 +40,17 @@ importer_default_props = ImporterProps(
|
|
|
40
40
|
def importer(props: ImporterProps) -> None:
|
|
41
41
|
log("Importing profile...")
|
|
42
42
|
if not props.profile:
|
|
43
|
-
log("No profile specified")
|
|
43
|
+
log("❌ No profile specified")
|
|
44
44
|
return
|
|
45
45
|
|
|
46
46
|
profile_path = Path(props.profile)
|
|
47
47
|
|
|
48
48
|
if not is_zipfile(profile_path):
|
|
49
|
-
log("Invalid Profile file")
|
|
49
|
+
log("❌ Invalid Profile file")
|
|
50
50
|
return
|
|
51
51
|
|
|
52
52
|
if profile_path.suffix != __EXPORT_EXTENSION__:
|
|
53
|
-
log("Unsupported Profile file")
|
|
53
|
+
log("❌ Unsupported Profile file")
|
|
54
54
|
return
|
|
55
55
|
|
|
56
56
|
# Setup variables
|
|
@@ -62,7 +62,7 @@ def importer(props: ImporterProps) -> None:
|
|
|
62
62
|
# Create profile branch
|
|
63
63
|
_, remote_profiles, active_profile, all_profiles = get_repo_branches(repo)
|
|
64
64
|
if profile_name in all_profiles:
|
|
65
|
-
log(f"Profile '{profile_name}' already exists")
|
|
65
|
+
log(f"❌ Profile '{profile_name}' already exists")
|
|
66
66
|
return
|
|
67
67
|
|
|
68
68
|
create_branch(repo=repo, branch=profile_name)
|
|
@@ -127,7 +127,7 @@ def importer(props: ImporterProps) -> None:
|
|
|
127
127
|
checkout_branch(repo, active_profile)
|
|
128
128
|
log(f"Switched back to profile: {active_profile}")
|
|
129
129
|
|
|
130
|
-
log("Profile Imported successfully!")
|
|
130
|
+
log("✅ Profile Imported successfully!")
|
|
131
131
|
|
|
132
132
|
finally:
|
|
133
133
|
shutil.rmtree(temp_profile_dir, ignore_errors=True)
|
|
@@ -47,7 +47,7 @@ def initialise(props: InitializerProps):
|
|
|
47
47
|
log("Initializing...")
|
|
48
48
|
|
|
49
49
|
if is_git_repo(props.dest):
|
|
50
|
-
log("Repository already initialized.")
|
|
50
|
+
log("❌ Repository already initialized.")
|
|
51
51
|
return
|
|
52
52
|
|
|
53
53
|
if props.git_url:
|
|
@@ -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
|
-
|
|
75
|
-
|
|
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}")
|
|
@@ -39,7 +39,7 @@ def remove(props: RemoverProps):
|
|
|
39
39
|
|
|
40
40
|
try:
|
|
41
41
|
if repo.bare:
|
|
42
|
-
print("The repository is bare. No profiles available.")
|
|
42
|
+
print("❌ The repository is bare. No profiles available.")
|
|
43
43
|
return
|
|
44
44
|
|
|
45
45
|
if props.fetch:
|
|
@@ -54,16 +54,16 @@ def remove(props: RemoverProps):
|
|
|
54
54
|
# Delete local branch if it exists
|
|
55
55
|
if profile in local_profiles:
|
|
56
56
|
delete_local_branch(repo, profile)
|
|
57
|
-
log(f"Local profile '{profile}' removed successfully.")
|
|
57
|
+
log(f"✅ Local profile '{profile}' removed successfully.")
|
|
58
58
|
else:
|
|
59
|
-
log(f"Profile '{profile}' does not exist locally.")
|
|
59
|
+
log(f"❎ Profile '{profile}' does not exist locally.")
|
|
60
60
|
|
|
61
61
|
# Delete remote branch if it exists
|
|
62
62
|
if is_remote_repo(repo=repo):
|
|
63
63
|
if profile in remote_profiles:
|
|
64
64
|
if props.no_confirm:
|
|
65
65
|
delete_remote_branch(repo, profile)
|
|
66
|
-
log(f"Remote profile '{profile}' removed successfully.")
|
|
66
|
+
log(f"✅ Remote profile '{profile}' removed successfully.")
|
|
67
67
|
return
|
|
68
68
|
else:
|
|
69
69
|
# Ask for confirmation
|
|
@@ -72,13 +72,13 @@ def remove(props: RemoverProps):
|
|
|
72
72
|
)
|
|
73
73
|
if confirm.lower() == "y":
|
|
74
74
|
delete_remote_branch(repo, profile)
|
|
75
|
-
log(f"Remote profile '{profile}' removed successfully.")
|
|
75
|
+
log(f"✅ Remote profile '{profile}' removed successfully.")
|
|
76
76
|
return
|
|
77
77
|
else:
|
|
78
|
-
log("Remote profile deletion aborted by user.")
|
|
78
|
+
log("🛑 Remote profile deletion aborted by user.")
|
|
79
79
|
return
|
|
80
80
|
|
|
81
|
-
log(f"Profile '{profile}' does not exist on cloud.")
|
|
81
|
+
log(f"❎ Profile '{profile}' does not exist on cloud.")
|
|
82
82
|
|
|
83
83
|
except Exception as e:
|
|
84
84
|
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
|
-
log("No changes detected!")
|
|
100
|
+
log("ℹ️ No changes detected!")
|
|
@@ -34,7 +34,7 @@ def switch(props: SwitcherProps):
|
|
|
34
34
|
repo = get_repo(props.profile_dir)
|
|
35
35
|
|
|
36
36
|
if repo.bare:
|
|
37
|
-
log("The repository is bare. No Profile available.")
|
|
37
|
+
log("❌ The repository is bare. No Profile available.")
|
|
38
38
|
sys.exit(1)
|
|
39
39
|
|
|
40
40
|
local_profiles, remote_profiles, active_profile, all_profiles = get_repo_branches(
|
|
@@ -52,7 +52,7 @@ def switch(props: SwitcherProps):
|
|
|
52
52
|
)
|
|
53
53
|
|
|
54
54
|
if profile_name == active_profile:
|
|
55
|
-
log(f"Already on the current profile: {profile_name}")
|
|
55
|
+
log(f"ℹ️ Already on the current profile: {profile_name}")
|
|
56
56
|
return
|
|
57
57
|
|
|
58
58
|
# Fetch remote branches if requested
|
|
@@ -64,10 +64,10 @@ def switch(props: SwitcherProps):
|
|
|
64
64
|
if profile_name in local_profiles:
|
|
65
65
|
# Checkout local branch
|
|
66
66
|
checkout_branch(repo, profile_name)
|
|
67
|
-
log(f"Switched to profile: {profile_name}")
|
|
67
|
+
log(f"✅ Switched to profile: {profile_name}")
|
|
68
68
|
elif profile_name in remote_profiles:
|
|
69
69
|
# Checkout and track remote branch automatically
|
|
70
70
|
checkout_branch(repo, profile_name)
|
|
71
|
-
log(f"Downloaded and switched to new profile from cloud: {profile_name}")
|
|
71
|
+
log(f"✅ Downloaded and switched to new profile from cloud: {profile_name}")
|
|
72
72
|
else:
|
|
73
|
-
log(f"Profile '{profile_name}' is not available in the repository.")
|
|
73
|
+
log(f"❌ Profile '{profile_name}' is not available in the repository.")
|
|
@@ -29,7 +29,7 @@ def wipe(props: WiperProps):
|
|
|
29
29
|
try:
|
|
30
30
|
if props.no_confirm:
|
|
31
31
|
shutil.rmtree(props.profile_dir)
|
|
32
|
-
log(f"Profile directory '{props.profile_dir}' removed successfully.")
|
|
32
|
+
log(f"🗑️ Profile directory '{props.profile_dir}' removed successfully.")
|
|
33
33
|
return
|
|
34
34
|
else:
|
|
35
35
|
# Ask for confirmation
|
|
@@ -42,12 +42,12 @@ def wipe(props: WiperProps):
|
|
|
42
42
|
timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
|
43
43
|
backup_dir = f"{props.profile_dir}_backup_{timestamp}"
|
|
44
44
|
shutil.copytree(props.profile_dir, backup_dir)
|
|
45
|
-
log(f"Backup directory '{backup_dir}' created successfully.")
|
|
45
|
+
log(f"💾 Backup directory '{backup_dir}' created successfully.")
|
|
46
46
|
shutil.rmtree(props.profile_dir)
|
|
47
|
-
log(f"Profile directory '{props.profile_dir}' removed successfully.")
|
|
47
|
+
log(f"🗑️ Profile directory '{props.profile_dir}' removed successfully.")
|
|
48
48
|
return
|
|
49
49
|
else:
|
|
50
|
-
log("Profile wipe process aborted by user.")
|
|
50
|
+
log("🛑 Profile wipe process aborted by user.")
|
|
51
51
|
return
|
|
52
52
|
except Exception as e:
|
|
53
53
|
raise Exception(f"Unexpected error: {e}")
|
|
@@ -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
|
|
97
|
+
return None
|
|
98
98
|
|
|
99
99
|
if custom_config:
|
|
100
100
|
log(f"Using custom config file: {custom_config}")
|
|
@@ -226,6 +226,35 @@ 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 not origin:
|
|
232
|
+
log("Warning: Skipping pull from remote repository! Not a remote repo.")
|
|
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
|
+
_, remote_profiles, active_profile, _ = get_repo_branches(repo)
|
|
241
|
+
|
|
242
|
+
if active_profile not in remote_profiles:
|
|
243
|
+
return None
|
|
244
|
+
|
|
245
|
+
local_commit = repo.commit(active_profile)
|
|
246
|
+
remote_commit = repo.commit(f"origin/{active_profile}")
|
|
247
|
+
|
|
248
|
+
if local_commit.hexsha == remote_commit.hexsha:
|
|
249
|
+
return None
|
|
250
|
+
|
|
251
|
+
log("📥 Update found:")
|
|
252
|
+
for commit in repo.iter_commits(f"{active_profile}..origin/{active_profile}"):
|
|
253
|
+
log(f" - {commit.summary} ({commit.hexsha[:7]})")
|
|
254
|
+
origin.pull()
|
|
255
|
+
return True
|
|
256
|
+
|
|
257
|
+
|
|
229
258
|
def get_repo_meta(repo: Repo) -> RepoMetaData:
|
|
230
259
|
|
|
231
260
|
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(
|
|
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
|
-
|
|
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.
|
|
3
|
+
Version: 1.0.8
|
|
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
|
|
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
|