diff --git a/src/dotctl/actions/activator.py b/src/dotctl/actions/activator.py index e0a674b..2c75284 100644 --- a/src/dotctl/actions/activator.py +++ b/src/dotctl/actions/activator.py @@ -54,13 +54,13 @@ def apply(props: ActivatorProps) -> None: checkout_branch(repo, profile) log(f"Switched to profile: {profile}") else: - log(f"Profile {profile} is not available.") + log(f"❌ Profile {profile} is not available.") return config = conf_reader(config_file=Path(app_config_file)) if pull_changes(repo): - log("✅ Pulled latest changes from cloud successfully.") + log("Pulled latest changes from cloud successfully.") if not props.skip_hooks and not props.skip_pre_hooks: run_hooks( @@ -95,4 +95,4 @@ def apply(props: ActivatorProps) -> None: ignore_errors=props.ignore_hook_errors, timeout=props.hooks_timeout, ) - log("✅ Profile saved successfully!") + log("✅ Profile applied successfully!") diff --git a/src/dotctl/actions/creator.py b/src/dotctl/actions/creator.py index d3e1a87..6ba0c03 100644 --- a/src/dotctl/actions/creator.py +++ b/src/dotctl/actions/creator.py @@ -53,7 +53,7 @@ def create(props: CreatorProps): _, _, _, all_profiles = get_repo_branches(repo) if props.profile in all_profiles: - log(f"Profile '{props.profile}' already exists.") + log(f"❌ Profile '{props.profile}' already exists.") return if props.env or props.config: if props.config is not None and isinstance(props.config, str): @@ -86,4 +86,4 @@ def create(props: CreatorProps): else: push_existing_branch(repo=repo) - log(f"Profile '{props.profile}' created and activated successfully.") + log(f"✅ Profile '{props.profile}' created and activated successfully.") diff --git a/src/dotctl/actions/exporter.py b/src/dotctl/actions/exporter.py index 1e68ec5..85d9d6d 100644 --- a/src/dotctl/actions/exporter.py +++ b/src/dotctl/actions/exporter.py @@ -67,7 +67,7 @@ def exporter(props: ExporterProps) -> None: checkout_branch(repo, profile) log(f"Switched to profile: {profile}") else: - log(f"Profile '{profile}' not found.") + log(f"❌ Profile '{profile}' not found.") return # Copy profile files @@ -117,7 +117,7 @@ def exporter(props: ExporterProps) -> None: shutil.move(archive_file, export_profile_path.with_suffix(__EXPORT_EXTENSION__)) log( - f"Successfully exported to {export_profile_path.with_suffix(__EXPORT_EXTENSION__)}" + f"✅ Successfully exported to {export_profile_path.with_suffix(__EXPORT_EXTENSION__)}" ) finally: shutil.rmtree(export_profile_path, ignore_errors=True) diff --git a/src/dotctl/actions/importer.py b/src/dotctl/actions/importer.py index b39412d..78e75b2 100644 --- a/src/dotctl/actions/importer.py +++ b/src/dotctl/actions/importer.py @@ -40,17 +40,17 @@ class ImporterProps: def importer(props: ImporterProps) -> None: log("Importing profile...") if not props.profile: - log("No profile specified") + log("❌ No profile specified") return profile_path = Path(props.profile) if not is_zipfile(profile_path): - log("Invalid Profile file") + log("❌ Invalid Profile file") return if profile_path.suffix != __EXPORT_EXTENSION__: - log("Unsupported Profile file") + log("❌ Unsupported Profile file") return # Setup variables @@ -62,7 +62,7 @@ def importer(props: ImporterProps) -> None: # Create profile branch _, remote_profiles, active_profile, all_profiles = get_repo_branches(repo) if profile_name in all_profiles: - log(f"Profile '{profile_name}' already exists") + log(f"❌ Profile '{profile_name}' already exists") return create_branch(repo=repo, branch=profile_name) @@ -127,7 +127,7 @@ def importer(props: ImporterProps) -> None: checkout_branch(repo, active_profile) log(f"Switched back to profile: {active_profile}") - log("Profile Imported successfully!") + log("✅ Profile Imported successfully!") finally: shutil.rmtree(temp_profile_dir, ignore_errors=True) diff --git a/src/dotctl/actions/initializer.py b/src/dotctl/actions/initializer.py index 1061e75..073c94e 100644 --- a/src/dotctl/actions/initializer.py +++ b/src/dotctl/actions/initializer.py @@ -47,7 +47,7 @@ def initialise(props: InitializerProps): log("Initializing...") if is_git_repo(props.dest): - log("Repository already initialized.") + log("❌ Repository already initialized.") return if props.git_url: diff --git a/src/dotctl/actions/puller.py b/src/dotctl/actions/puller.py index 252964b..e27cb16 100644 --- a/src/dotctl/actions/puller.py +++ b/src/dotctl/actions/puller.py @@ -26,7 +26,7 @@ def pull(props: PullerProps): try: changes = pull_changes(repo) if changes is None: - log("✅ Profile already up to date.") + log("ℹ️ Profile already up to date.") elif changes: log("✅ Pulled latest changes successfully.") diff --git a/src/dotctl/actions/remover.py b/src/dotctl/actions/remover.py index 0cb1483..83d1b61 100644 --- a/src/dotctl/actions/remover.py +++ b/src/dotctl/actions/remover.py @@ -39,7 +39,7 @@ def remove(props: RemoverProps): try: if repo.bare: - print("The repository is bare. No profiles available.") + print("❌ The repository is bare. No profiles available.") return if props.fetch: @@ -54,16 +54,16 @@ def remove(props: RemoverProps): # Delete local branch if it exists if profile in local_profiles: delete_local_branch(repo, profile) - log(f"Local profile '{profile}' removed successfully.") + log(f"✅ Local profile '{profile}' removed successfully.") else: - log(f"Profile '{profile}' does not exist locally.") + log(f"❎ Profile '{profile}' does not exist locally.") # Delete remote branch if it exists if is_remote_repo(repo=repo): if profile in remote_profiles: if props.no_confirm: delete_remote_branch(repo, profile) - log(f"Remote profile '{profile}' removed successfully.") + log(f"✅ Remote profile '{profile}' removed successfully.") return else: # Ask for confirmation @@ -72,13 +72,13 @@ def remove(props: RemoverProps): ) if confirm.lower() == "y": delete_remote_branch(repo, profile) - log(f"Remote profile '{profile}' removed successfully.") + log(f"✅ Remote profile '{profile}' removed successfully.") return else: - log("Remote profile deletion aborted by user.") + log("🛑 Remote profile deletion aborted by user.") return - log(f"Profile '{profile}' does not exist on cloud.") + log(f"❎ Profile '{profile}' does not exist on cloud.") except Exception as e: raise Exception(f"Unexpected error: {e}") diff --git a/src/dotctl/actions/saver.py b/src/dotctl/actions/saver.py index 1bff8e1..80e289c 100644 --- a/src/dotctl/actions/saver.py +++ b/src/dotctl/actions/saver.py @@ -56,7 +56,7 @@ def save(props: SaverProps) -> None: create_branch(repo=repo, branch=profile) log(f"Profile '{profile}' created and activated successfully.") if pull_changes(repo): - log("✅ Pulled latest changes from cloud successfully.") + log("Pulled latest changes from cloud successfully.") config = conf_reader(config_file=Path(app_config_file)) @@ -97,4 +97,4 @@ def save(props: SaverProps) -> None: push_existing_branch(repo=repo) log("✅ Profile saved successfully!") else: - log("No changes detected!") + log("ℹ️ No changes detected!") diff --git a/src/dotctl/actions/switcher.py b/src/dotctl/actions/switcher.py index 3d147aa..b84fedc 100644 --- a/src/dotctl/actions/switcher.py +++ b/src/dotctl/actions/switcher.py @@ -34,7 +34,7 @@ def switch(props: SwitcherProps): repo = get_repo(props.profile_dir) if repo.bare: - log("The repository is bare. No Profile available.") + log("❌ The repository is bare. No Profile available.") sys.exit(1) local_profiles, remote_profiles, active_profile, all_profiles = get_repo_branches( @@ -52,7 +52,7 @@ def switch(props: SwitcherProps): ) if profile_name == active_profile: - log(f"Already on the current profile: {profile_name}") + log(f"ℹ️ Already on the current profile: {profile_name}") return # Fetch remote branches if requested @@ -64,10 +64,10 @@ def switch(props: SwitcherProps): if profile_name in local_profiles: # Checkout local branch checkout_branch(repo, profile_name) - log(f"Switched to profile: {profile_name}") + log(f"✅ Switched to profile: {profile_name}") elif profile_name in remote_profiles: # Checkout and track remote branch automatically checkout_branch(repo, profile_name) - log(f"Downloaded and switched to new profile from cloud: {profile_name}") + log(f"✅ Downloaded and switched to new profile from cloud: {profile_name}") else: - log(f"Profile '{profile_name}' is not available in the repository.") + log(f"❌ Profile '{profile_name}' is not available in the repository.") diff --git a/src/dotctl/actions/wiper.py b/src/dotctl/actions/wiper.py index 549ebac..20f88f0 100644 --- a/src/dotctl/actions/wiper.py +++ b/src/dotctl/actions/wiper.py @@ -29,7 +29,7 @@ def wipe(props: WiperProps): try: if props.no_confirm: shutil.rmtree(props.profile_dir) - log(f"Profile directory '{props.profile_dir}' removed successfully.") + log(f"🗑️ Profile directory '{props.profile_dir}' removed successfully.") return else: # Ask for confirmation @@ -42,12 +42,12 @@ def wipe(props: WiperProps): timestamp = datetime.now().strftime("%Y-%m-%d_%H-%M-%S") backup_dir = f"{props.profile_dir}_backup_{timestamp}" shutil.copytree(props.profile_dir, backup_dir) - log(f"Backup directory '{backup_dir}' created successfully.") + log(f"💾 Backup directory '{backup_dir}' created successfully.") shutil.rmtree(props.profile_dir) - log(f"Profile directory '{props.profile_dir}' removed successfully.") + log(f"🗑️ Profile directory '{props.profile_dir}' removed successfully.") return else: - log("Profile wipe process aborted by user.") + log("🛑 Profile wipe process aborted by user.") return except Exception as e: raise Exception(f"Unexpected error: {e}") diff --git a/src/dotctl/handlers/git_handler.py b/src/dotctl/handlers/git_handler.py index 1c1d66d..cfb36cc 100644 --- a/src/dotctl/handlers/git_handler.py +++ b/src/dotctl/handlers/git_handler.py @@ -228,8 +228,8 @@ def push_new_branch(repo: Repo) -> None: def pull_changes(repo: Repo) -> bool | None: is_remote, origin = is_remote_repo(repo) - if not is_remote or origin is None: - log("Warning: Skipping pull. This is not a remote repository.") + if not is_remote or not origin: + log("Warning: Skipping pull from remote repository! Not a remote repo.") return None if repo.bare: @@ -237,17 +237,20 @@ def pull_changes(repo: Repo) -> bool | None: git_fetch(repo) - current_branch = repo.active_branch.name - local_commit = repo.commit(current_branch) - remote_commit = repo.commit(f"origin/{current_branch}") + _, remote_profiles, active_profile, _ = get_repo_branches(repo) + + if active_profile not in remote_profiles: + return None + + local_commit = repo.commit(active_profile) + remote_commit = repo.commit(f"origin/{active_profile}") if local_commit.hexsha == remote_commit.hexsha: return None log("📥 Update found:") - for commit in repo.iter_commits(f"{current_branch}..origin/{current_branch}"): - log(f" - {commit.summary} ({commit.hexsha[:7]})") - + for commit in repo.iter_commits(f"{active_profile}..origin/{active_profile}"): + log(f" - {commit.summary} ({commit.hexsha[:7]})") origin.pull() return True