git-repokit 0.9.10__py3-none-any.whl
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.
- git_repokit-0.9.10.dist-info/METADATA +422 -0
- git_repokit-0.9.10.dist-info/RECORD +174 -0
- git_repokit-0.9.10.dist-info/WHEEL +5 -0
- git_repokit-0.9.10.dist-info/entry_points.txt +2 -0
- git_repokit-0.9.10.dist-info/licenses/LICENSE +9 -0
- git_repokit-0.9.10.dist-info/top_level.txt +1 -0
- repokit/__init__.py +8 -0
- repokit/__main__.py +12 -0
- repokit/__version__.py +4 -0
- repokit/_vendor/__init__.py +0 -0
- repokit/_vendor/ailib/__init__.py +1 -0
- repokit/_vendor/ailib/analyzer.py +177 -0
- repokit/_vendor/ailib/backend.py +95 -0
- repokit/_vendor/ailib/cache.py +97 -0
- repokit/_vendor/ailib/parsers.py +52 -0
- repokit/_vendor/ailib/transports/__init__.py +16 -0
- repokit/_vendor/ailib/transports/cli.py +312 -0
- repokit/_vendor/ailib/transports/openai_compat.py +383 -0
- repokit/_vendor/ailib/transports/prompt_file.py +41 -0
- repokit/_vendor/ailib/types.py +224 -0
- repokit/auth_integration.py +244 -0
- repokit/badges.py +183 -0
- repokit/branch_utils.py +364 -0
- repokit/cli.py +2997 -0
- repokit/common_kit.py +202 -0
- repokit/config.py +686 -0
- repokit/defaults.py +220 -0
- repokit/directory_analyzer.py +1244 -0
- repokit/directory_profiles.py +423 -0
- repokit/git_config.py +370 -0
- repokit/github_create.py +142 -0
- repokit/github_setup.py +248 -0
- repokit/guardrails.py +707 -0
- repokit/history_cleaner.py +449 -0
- repokit/history_protection.py +434 -0
- repokit/hooks/pre-commit-guardrails +122 -0
- repokit/hooks/pre-commit-template +28 -0
- repokit/layers.py +510 -0
- repokit/licenses/0bsd.txt +14 -0
- repokit/licenses/LICENSES.md +27 -0
- repokit/licenses/__init__.py +142 -0
- repokit/licenses/agpl-3.0.txt +661 -0
- repokit/licenses/all-rights-reserved.txt +10 -0
- repokit/licenses/apache-2.0.txt +201 -0
- repokit/licenses/bsd-2-clause.txt +24 -0
- repokit/licenses/bsd-3-clause.txt +28 -0
- repokit/licenses/bsl-1.0.txt +23 -0
- repokit/licenses/cc-by-4.0.txt +395 -0
- repokit/licenses/cc-by-sa-4.0.txt +427 -0
- repokit/licenses/cc0-1.0.txt +121 -0
- repokit/licenses/epl-2.0.txt +277 -0
- repokit/licenses/gpl-2.0.txt +339 -0
- repokit/licenses/gpl-3.0.txt +674 -0
- repokit/licenses/isc.txt +15 -0
- repokit/licenses/lgpl-2.1.txt +504 -0
- repokit/licenses/lgpl-3.0.txt +165 -0
- repokit/licenses/mit.txt +21 -0
- repokit/licenses/mpl-2.0.txt +373 -0
- repokit/licenses/unlicense.txt +24 -0
- repokit/readme_blocks.py +112 -0
- repokit/remote_integration.py +627 -0
- repokit/repo_manager.py +2796 -0
- repokit/template_engine.py +391 -0
- repokit/templates/ai/claude/CLAUDE-nested.md.template +25 -0
- repokit/templates/ai/claude/CLAUDE.md.template +98 -0
- repokit/templates/ai/claude/instructions/step1_context_rebuilder.md +33 -0
- repokit/templates/ai/claude/instructions/step2_dev_workflow_process.md +67 -0
- repokit/templates/ai/claude/instructions/step3_context_bridge.md +52 -0
- repokit/templates/common/CHANGELOG.md.template +15 -0
- repokit/templates/common/CONTRIBUTING.md.template +31 -0
- repokit/templates/common/README.md.template +30 -0
- repokit/templates/common/gitattributes.template +17 -0
- repokit/templates/common/gitignore.template +141 -0
- repokit/templates/extras/FUNDING.yml.template +13 -0
- repokit/templates/extras/ROADMAP.md.template +17 -0
- repokit/templates/extras/dependabot.yml.template +22 -0
- repokit/templates/extras/one-offs-README.md.template +28 -0
- repokit/templates/extras/platform-support.md.template +11 -0
- repokit/templates/extras/pull_request_template.md.template +25 -0
- repokit/templates/extras/release-template.md.template +34 -0
- repokit/templates/extras/settings.json.template +11 -0
- repokit/templates/extras/stale.yml.template +14 -0
- repokit/templates/github/CODEOWNERS.template +11 -0
- repokit/templates/github/ISSUE_TEMPLATE/bug-report.md.template +29 -0
- repokit/templates/github/ISSUE_TEMPLATE/feature-request.md.template +19 -0
- repokit/templates/github/issues/notes.md.template +18 -0
- repokit/templates/github/issues/roadmap.md.template +15 -0
- repokit/templates/hooks/pre-commit.template +64 -0
- repokit/templates/layers/archetypes/any/claude-plugin/.claude-plugin/marketplace.json +20 -0
- repokit/templates/layers/archetypes/any/claude-plugin/plugin/.claude-plugin/plugin.json +15 -0
- repokit/templates/layers/archetypes/any/claude-plugin/plugin/README.md +28 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/.github/workflows/ci-c-cpp.yml +24 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/.repokit-common.toml.rkappend +4 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/.vscode/launch.json +29 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/.vscode/tasks.json +26 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/CMakeLists.txt +47 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/CMakePresets.json +23 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/cmake/GenerateStamp.cmake +45 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/src/main.cpp +27 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/tests/test_version.cpp +20 -0
- repokit/templates/layers/archetypes/c-cpp/cmake-app/vcpkg.json +5 -0
- repokit/templates/layers/archetypes/c-cpp/minimal/.vscode/launch.json +27 -0
- repokit/templates/layers/archetypes/c-cpp/minimal/Makefile +10 -0
- repokit/templates/layers/archetypes/c-cpp/minimal/build.bat +7 -0
- repokit/templates/layers/archetypes/c-cpp/minimal/src/__RK_SNAKE__.c +26 -0
- repokit/templates/layers/archetypes/c-cpp/msbuild/.vscode/launch.json +17 -0
- repokit/templates/layers/archetypes/c-cpp/msbuild/.vscode/tasks.json +20 -0
- repokit/templates/layers/archetypes/c-cpp/msbuild/__RK_PROJECT__.sln +19 -0
- repokit/templates/layers/archetypes/c-cpp/msbuild/__RK_PROJECT__.vcxproj +41 -0
- repokit/templates/layers/archetypes/c-cpp/msbuild/src/main.cpp +26 -0
- repokit/templates/layers/archetypes/js-ts/claude-plugin/.repokit-common.toml +28 -0
- repokit/templates/layers/archetypes/js-ts/claude-plugin/.vscode/launch.json +34 -0
- repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/hooks/hooks.json +15 -0
- repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/hooks/scripts/session-start.mjs +23 -0
- repokit/templates/layers/archetypes/js-ts/claude-plugin/plugin/tests/manifest.test.js +30 -0
- repokit/templates/layers/archetypes/js-ts/node/.repokit-common.toml.rkappend +6 -0
- repokit/templates/layers/archetypes/js-ts/node/package.json +13 -0
- repokit/templates/layers/archetypes/js-ts/node-package/.github/workflows/release.yml +39 -0
- repokit/templates/layers/archetypes/js-ts/node-package/package.json +32 -0
- repokit/templates/layers/archetypes/js-ts/node-package/src/index.ts +13 -0
- repokit/templates/layers/archetypes/js-ts/node-package/tests/index.test.ts +11 -0
- repokit/templates/layers/archetypes/js-ts/script/.vscode/launch.json +34 -0
- repokit/templates/layers/archetypes/js-ts/script/__RK_PROJECT__.js +37 -0
- repokit/templates/layers/archetypes/js-ts/script/tests/version.test.js +26 -0
- repokit/templates/layers/archetypes/js-ts/ts/package.json +18 -0
- repokit/templates/layers/archetypes/js-ts/ts/tsconfig.json +15 -0
- repokit/templates/layers/archetypes/python/claude-plugin/.github/workflows/ci-python.yml +44 -0
- repokit/templates/layers/archetypes/python/claude-plugin/.repokit-common.toml +21 -0
- repokit/templates/layers/archetypes/python/claude-plugin/.vscode/launch.json +33 -0
- repokit/templates/layers/archetypes/python/claude-plugin/VERSION +1 -0
- repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/hooks.json +15 -0
- repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/scripts/run-hook.mjs +42 -0
- repokit/templates/layers/archetypes/python/claude-plugin/plugin/hooks/scripts/session_start.py +31 -0
- repokit/templates/layers/archetypes/python/claude-plugin/plugin/tests/test_manifest.py +42 -0
- repokit/templates/layers/archetypes/python/pypi/.github/workflows/release.yml +63 -0
- repokit/templates/layers/archetypes/python/pypi/.vscode/launch.json +43 -0
- repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/__init__.py +5 -0
- repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/__main__.py +6 -0
- repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/_version.py +96 -0
- repokit/templates/layers/archetypes/python/pypi/__RK_SNAKE__/cli.py +18 -0
- repokit/templates/layers/archetypes/python/pypi/pyproject.toml +71 -0
- repokit/templates/layers/archetypes/python/pypi/tests/conftest.py +11 -0
- repokit/templates/layers/archetypes/python/pypi/tests/test_version.py +50 -0
- repokit/templates/layers/archetypes/python/script/.github/workflows/ci-python.yml +43 -0
- repokit/templates/layers/archetypes/python/script/.repokit-common.toml +14 -0
- repokit/templates/layers/archetypes/python/script/.vscode/launch.json +33 -0
- repokit/templates/layers/archetypes/python/script/VERSION +1 -0
- repokit/templates/layers/archetypes/python/script/__RK_PROJECT__.py +40 -0
- repokit/templates/layers/archetypes/python/script/tests/test_version.py +25 -0
- repokit/templates/layers/archetypes/python/setuppy/requirements.txt +8 -0
- repokit/templates/layers/archetypes/python/setuppy/setup.py +23 -0
- repokit/templates/layers/languages/c-cpp/.gitignore.rkappend +20 -0
- repokit/templates/layers/languages/c-cpp/.repokit-common.toml +7 -0
- repokit/templates/layers/languages/c-cpp/include/__RK_SNAKE__/version.h +20 -0
- repokit/templates/layers/languages/c-cpp/src/app.rc +25 -0
- repokit/templates/layers/languages/js-ts/.editorconfig +15 -0
- repokit/templates/layers/languages/js-ts/.github/workflows/ci-js-ts.yml +41 -0
- repokit/templates/layers/languages/js-ts/.gitignore.rkappend +13 -0
- repokit/templates/layers/languages/js-ts/.repokit-common.toml +19 -0
- repokit/templates/layers/languages/js-ts/.vscode/launch.json +24 -0
- repokit/templates/layers/languages/js-ts/VERSION +1 -0
- repokit/templates/layers/languages/python/.github/workflows/ci-python.yml +76 -0
- repokit/templates/layers/languages/python/.gitignore.rkappend +15 -0
- repokit/templates/layers/languages/python/.vscode/launch.json +33 -0
- repokit/templates/layers/manifest.toml +302 -0
- repokit/templates/vault/CLAUDE.md +29 -0
- repokit/templates/vault/claude/_maps/MOC-project.md +15 -0
- repokit/templates/vault/claude/_oracle/backlinks.md +3 -0
- repokit/templates/vault/claude/_oracle/concepts.md +12 -0
- repokit/templates/vault/claude/_oracle/manifest.md +10 -0
- repokit/templates/vault/claude/_todo/ACTIVE-WORK.md +18 -0
- repokit/templates/vault/claude/_todo/OPEN-LOOPS.md +14 -0
- repokit/utils.py +316 -0
- repokit/vault.py +248 -0
repokit/guardrails.py
ADDED
|
@@ -0,0 +1,707 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
RepoKit Guardrails - Protection against private content leakage.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import shutil
|
|
8
|
+
import stat
|
|
9
|
+
import subprocess
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Optional, List, Dict
|
|
12
|
+
|
|
13
|
+
from .branch_utils import BranchContext
|
|
14
|
+
from .utils import logger
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class GuardrailsManager:
|
|
18
|
+
"""Manages RepoKit guardrails for private content protection."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, repo_path: str = '.'):
|
|
21
|
+
"""Initialize guardrails manager."""
|
|
22
|
+
self.repo_path = Path(repo_path).resolve()
|
|
23
|
+
self.git_dir = self.repo_path / '.git'
|
|
24
|
+
self.hooks_dir = self.git_dir / 'hooks'
|
|
25
|
+
self.context = BranchContext(str(self.repo_path))
|
|
26
|
+
|
|
27
|
+
def setup_guardrails(self, force: bool = False) -> bool:
|
|
28
|
+
"""
|
|
29
|
+
Set up all guardrails for the repository.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
force: Overwrite existing hooks if True
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
True if successful, False otherwise
|
|
36
|
+
"""
|
|
37
|
+
logger.info("Setting up RepoKit guardrails...")
|
|
38
|
+
|
|
39
|
+
# Ensure we're in a git repository
|
|
40
|
+
if not self.git_dir.exists():
|
|
41
|
+
logger.error("Not in a git repository!")
|
|
42
|
+
return False
|
|
43
|
+
|
|
44
|
+
# Create hooks directory if needed
|
|
45
|
+
self.hooks_dir.mkdir(exist_ok=True)
|
|
46
|
+
|
|
47
|
+
# Set up pre-commit hook
|
|
48
|
+
if not self._install_hook('pre-commit', force):
|
|
49
|
+
return False
|
|
50
|
+
|
|
51
|
+
# Set up branch excludes
|
|
52
|
+
self.context.setup_branch_excludes()
|
|
53
|
+
|
|
54
|
+
# Set up post-checkout hook for automatic exclude updates
|
|
55
|
+
if not self._install_hook('post-checkout', force):
|
|
56
|
+
return False
|
|
57
|
+
|
|
58
|
+
logger.info("✅ RepoKit guardrails successfully installed!")
|
|
59
|
+
self._print_status()
|
|
60
|
+
|
|
61
|
+
return True
|
|
62
|
+
|
|
63
|
+
def _vendored_common(self) -> Optional[Path]:
|
|
64
|
+
"""The project's git-repokit-common copy (the folder with install-hooks.sh), if any."""
|
|
65
|
+
for candidate in (self.repo_path / "scripts" / "repokit-common", self.repo_path / "scripts"):
|
|
66
|
+
if (candidate / "install-hooks.sh").is_file() and (candidate / "repokit_config.py").is_file():
|
|
67
|
+
return candidate
|
|
68
|
+
return None
|
|
69
|
+
|
|
70
|
+
def setup_repokit_common(self, vendor: bool = False) -> int:
|
|
71
|
+
"""Install git-repokit-common's hooks, with the private-branch settings.
|
|
72
|
+
|
|
73
|
+
Never vendors silently: adding the subtree makes commits, so it needs
|
|
74
|
+
--vendor and a clean working tree. Returns a process exit code.
|
|
75
|
+
"""
|
|
76
|
+
from . import common_kit
|
|
77
|
+
from .defaults import DEFAULT_PRIVATE_DIRS, DEFAULT_SENSITIVE_FILES
|
|
78
|
+
|
|
79
|
+
if not self.git_dir.exists():
|
|
80
|
+
logger.error("Not in a git repository!")
|
|
81
|
+
return 1
|
|
82
|
+
|
|
83
|
+
copy = self._vendored_common()
|
|
84
|
+
if copy is None:
|
|
85
|
+
src = common_kit.source({})
|
|
86
|
+
url, ref = src if src else (common_kit.DEFAULT_URL, common_kit.DEFAULT_REF)
|
|
87
|
+
if not vendor:
|
|
88
|
+
print("This project has no git-repokit-common copy, whose hooks the guardrails use.")
|
|
89
|
+
print("Add it (two commits on the current branch), then re-run:")
|
|
90
|
+
print(f" git subtree add --prefix={common_kit.PREFIX} {url} {ref} --squash")
|
|
91
|
+
print("or run: repokit setup-guardrails --vendor")
|
|
92
|
+
print("(repokit setup-guardrails --legacy installs git-repokit's previous hooks instead.)")
|
|
93
|
+
return 1
|
|
94
|
+
dirty = subprocess.run(["git", "status", "--porcelain", "--untracked-files=no"],
|
|
95
|
+
cwd=self.repo_path, capture_output=True, text=True).stdout.strip()
|
|
96
|
+
if dirty:
|
|
97
|
+
print("The working tree has uncommitted changes; commit or stash them before --vendor.")
|
|
98
|
+
return 1
|
|
99
|
+
problem = common_kit.vendor(str(self.repo_path), url, ref)
|
|
100
|
+
if problem:
|
|
101
|
+
print(f"Could not add git-repokit-common: {problem}")
|
|
102
|
+
return 1
|
|
103
|
+
print(f"Added git-repokit-common at {common_kit.PREFIX}/")
|
|
104
|
+
print(common_kit.RESIGN_HINT)
|
|
105
|
+
copy = self._vendored_common()
|
|
106
|
+
|
|
107
|
+
private_paths = ["CLAUDE.md"] + [f"{d.rstrip('/')}/" for d in DEFAULT_PRIVATE_DIRS] + list(DEFAULT_SENSITIVE_FILES)
|
|
108
|
+
private_branch = self.context.current_branch if self.context.is_private_branch() else None
|
|
109
|
+
written = common_kit.write_settings(
|
|
110
|
+
str(self.repo_path), common_kit.private_branch_settings(private_branch, private_paths))
|
|
111
|
+
if written:
|
|
112
|
+
print(f"Wrote the private-branch settings to {written} -- commit it on every branch that should be checked.")
|
|
113
|
+
|
|
114
|
+
# install-hooks.sh asks before replacing a pre-commit that is not one
|
|
115
|
+
# of its stubs, and cannot be answered from here. Running this command
|
|
116
|
+
# is the request to switch, so move the old hooks aside -- renamed,
|
|
117
|
+
# never deleted -- and let it install into a free slot.
|
|
118
|
+
for name, suffix, mine in (
|
|
119
|
+
("pre-commit", ".before-repokit-common", lambda t: "repokit-common hook stub" not in t),
|
|
120
|
+
("post-checkout", ".disabled", lambda t: "RepoKit" in t and "post-checkout" in t.lower()),
|
|
121
|
+
):
|
|
122
|
+
hook = self.hooks_dir / name
|
|
123
|
+
if hook.is_file() and mine(hook.read_text(encoding="utf-8", errors="replace")):
|
|
124
|
+
target = self.hooks_dir / (name + suffix)
|
|
125
|
+
n = 1
|
|
126
|
+
while target.exists():
|
|
127
|
+
n += 1
|
|
128
|
+
target = self.hooks_dir / f"{name}{suffix}.{n}"
|
|
129
|
+
hook.rename(target)
|
|
130
|
+
print(f"Moved the previous {name} hook to {target.name}")
|
|
131
|
+
|
|
132
|
+
problem = common_kit.install_hooks(str(self.repo_path))
|
|
133
|
+
if problem:
|
|
134
|
+
print(f"Could not install the hooks: {problem}")
|
|
135
|
+
return 1
|
|
136
|
+
|
|
137
|
+
# Branch-specific exclusions (a setup step, not a hook) stay git-repokit's
|
|
138
|
+
self.context.setup_branch_excludes()
|
|
139
|
+
|
|
140
|
+
print("git-repokit-common hooks installed (pre-commit, post-commit, pre-push).")
|
|
141
|
+
self._print_status()
|
|
142
|
+
return 0
|
|
143
|
+
|
|
144
|
+
def _install_hook(self, hook_name: str, force: bool = False) -> bool:
|
|
145
|
+
"""Install a specific git hook."""
|
|
146
|
+
hook_path = self.hooks_dir / hook_name
|
|
147
|
+
|
|
148
|
+
# Check if hook already exists
|
|
149
|
+
if hook_path.exists() and not force:
|
|
150
|
+
logger.warning(f"Hook {hook_name} already exists. Use --force to overwrite.")
|
|
151
|
+
return True
|
|
152
|
+
|
|
153
|
+
# Get hook content based on type
|
|
154
|
+
if hook_name == 'pre-commit':
|
|
155
|
+
hook_content = self._get_pre_commit_hook()
|
|
156
|
+
elif hook_name == 'post-checkout':
|
|
157
|
+
hook_content = self._get_post_checkout_hook()
|
|
158
|
+
else:
|
|
159
|
+
logger.error(f"Unknown hook type: {hook_name}")
|
|
160
|
+
return False
|
|
161
|
+
|
|
162
|
+
# Write hook file
|
|
163
|
+
try:
|
|
164
|
+
# Hook templates are UTF-8; Windows' default codec cannot write them
|
|
165
|
+
hook_path.write_text(hook_content, encoding='utf-8')
|
|
166
|
+
# Make executable
|
|
167
|
+
hook_path.chmod(hook_path.stat().st_mode | stat.S_IEXEC)
|
|
168
|
+
logger.info(f"✓ Installed {hook_name} hook")
|
|
169
|
+
return True
|
|
170
|
+
except Exception as e:
|
|
171
|
+
logger.error(f"Failed to install {hook_name} hook: {e}")
|
|
172
|
+
return False
|
|
173
|
+
|
|
174
|
+
def _get_pre_commit_hook(self) -> str:
|
|
175
|
+
"""Get pre-commit hook content."""
|
|
176
|
+
# Try to use the template we created
|
|
177
|
+
template_path = Path(__file__).parent / 'hooks' / 'pre-commit-guardrails'
|
|
178
|
+
if template_path.exists():
|
|
179
|
+
return template_path.read_text(encoding='utf-8')
|
|
180
|
+
|
|
181
|
+
# Fallback to inline version
|
|
182
|
+
return '''#!/usr/bin/env python3
|
|
183
|
+
"""RepoKit pre-commit hook for private content protection."""
|
|
184
|
+
|
|
185
|
+
import sys
|
|
186
|
+
import os
|
|
187
|
+
|
|
188
|
+
# Try to use installed repokit
|
|
189
|
+
try:
|
|
190
|
+
from repokit.branch_utils import BranchContext
|
|
191
|
+
|
|
192
|
+
context = BranchContext()
|
|
193
|
+
print(f"🔍 RepoKit Pre-Commit Check")
|
|
194
|
+
print(f" Branch: {context.current_branch} ({context.branch_type})")
|
|
195
|
+
|
|
196
|
+
is_valid, errors = context.validate_commit()
|
|
197
|
+
|
|
198
|
+
if not is_valid:
|
|
199
|
+
print("\\n❌ COMMIT BLOCKED - Private Content Protection\\n")
|
|
200
|
+
for error in errors:
|
|
201
|
+
print(error)
|
|
202
|
+
sys.exit(1)
|
|
203
|
+
|
|
204
|
+
print("\\n✅ Pre-commit checks passed!")
|
|
205
|
+
sys.exit(0)
|
|
206
|
+
|
|
207
|
+
except ImportError:
|
|
208
|
+
# RepoKit not installed, basic check
|
|
209
|
+
import subprocess
|
|
210
|
+
|
|
211
|
+
result = subprocess.run(['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
|
212
|
+
capture_output=True, text=True)
|
|
213
|
+
branch = result.stdout.strip()
|
|
214
|
+
|
|
215
|
+
if branch not in ['private', 'local']:
|
|
216
|
+
# Check for obvious private files
|
|
217
|
+
result = subprocess.run(['git', 'diff', '--cached', '--name-only'],
|
|
218
|
+
capture_output=True, text=True)
|
|
219
|
+
files = result.stdout.strip().split('\\n')
|
|
220
|
+
|
|
221
|
+
private_files = [f for f in files if 'CLAUDE.md' in f or 'private/' in f]
|
|
222
|
+
|
|
223
|
+
if private_files:
|
|
224
|
+
print(f"\\n❌ ERROR: Attempting to commit private files to branch '{branch}':")
|
|
225
|
+
for f in private_files:
|
|
226
|
+
print(f" - {f}")
|
|
227
|
+
print("\\nThese files should only exist in private branches!")
|
|
228
|
+
sys.exit(1)
|
|
229
|
+
|
|
230
|
+
sys.exit(0)
|
|
231
|
+
'''
|
|
232
|
+
|
|
233
|
+
def _get_post_checkout_hook(self) -> str:
|
|
234
|
+
"""Get post-checkout hook content."""
|
|
235
|
+
return '''#!/bin/sh
|
|
236
|
+
# RepoKit Cross-Environment Post-Checkout Hook
|
|
237
|
+
# This wrapper script detects the environment and calls Python appropriately
|
|
238
|
+
|
|
239
|
+
# Function to detect Python command
|
|
240
|
+
find_python() {
|
|
241
|
+
# Try to detect if we're on Windows
|
|
242
|
+
if [ -n "$WINDIR" ] || [ "$OSTYPE" = "msys" ] || [ "$OSTYPE" = "cygwin" ]; then
|
|
243
|
+
# Windows environment - try various Python commands
|
|
244
|
+
if command -v py >/dev/null 2>&1; then
|
|
245
|
+
echo "py"
|
|
246
|
+
elif command -v python >/dev/null 2>&1; then
|
|
247
|
+
echo "python"
|
|
248
|
+
elif command -v python3 >/dev/null 2>&1; then
|
|
249
|
+
echo "python3"
|
|
250
|
+
else
|
|
251
|
+
echo ""
|
|
252
|
+
fi
|
|
253
|
+
else
|
|
254
|
+
# Unix/Linux/WSL environment
|
|
255
|
+
if command -v python3 >/dev/null 2>&1; then
|
|
256
|
+
echo "python3"
|
|
257
|
+
elif command -v python >/dev/null 2>&1; then
|
|
258
|
+
echo "python"
|
|
259
|
+
else
|
|
260
|
+
echo ""
|
|
261
|
+
fi
|
|
262
|
+
fi
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
# Find Python command
|
|
266
|
+
PYTHON_CMD=$(find_python)
|
|
267
|
+
|
|
268
|
+
# If Python not found, exit gracefully
|
|
269
|
+
if [ -z "$PYTHON_CMD" ]; then
|
|
270
|
+
echo "⚠️ Python not found - skipping RepoKit post-checkout tasks"
|
|
271
|
+
echo " To enable: Install Python and ensure it's in PATH"
|
|
272
|
+
exit 0
|
|
273
|
+
fi
|
|
274
|
+
|
|
275
|
+
# Execute the Python script with all arguments (UTF-8 output: its messages
|
|
276
|
+
# contain emoji, which a non-UTF-8 console cannot encode)
|
|
277
|
+
PYTHONIOENCODING=utf-8 $PYTHON_CMD - "$@" << 'EOF'
|
|
278
|
+
"""RepoKit post-checkout hook to update excludes and restore private files."""
|
|
279
|
+
|
|
280
|
+
import sys
|
|
281
|
+
import os
|
|
282
|
+
import subprocess
|
|
283
|
+
import shutil
|
|
284
|
+
from pathlib import Path
|
|
285
|
+
|
|
286
|
+
try:
|
|
287
|
+
from repokit.branch_utils import BranchContext
|
|
288
|
+
|
|
289
|
+
# Get the new branch (third argument)
|
|
290
|
+
if len(sys.argv) > 3:
|
|
291
|
+
# Full checkout (not file checkout)
|
|
292
|
+
if sys.argv[3] == '1':
|
|
293
|
+
context = BranchContext()
|
|
294
|
+
print(f"\\n🔄 Switched to branch: {context.current_branch}")
|
|
295
|
+
|
|
296
|
+
# Update branch excludes
|
|
297
|
+
context.setup_branch_excludes()
|
|
298
|
+
|
|
299
|
+
# Handle private file restoration
|
|
300
|
+
if context.is_public_branch():
|
|
301
|
+
# Restore private files from private branch
|
|
302
|
+
print("📄 Restoring private files for AI assistance...")
|
|
303
|
+
|
|
304
|
+
# Files to restore
|
|
305
|
+
private_files = [
|
|
306
|
+
'CLAUDE.md',
|
|
307
|
+
'private/claude/',
|
|
308
|
+
'private/docs/',
|
|
309
|
+
]
|
|
310
|
+
|
|
311
|
+
try:
|
|
312
|
+
# Get the current commit of private branch
|
|
313
|
+
result = subprocess.run(
|
|
314
|
+
['git', 'rev-parse', 'private'],
|
|
315
|
+
capture_output=True, text=True
|
|
316
|
+
)
|
|
317
|
+
private_commit = result.stdout.strip()
|
|
318
|
+
|
|
319
|
+
if result.returncode == 0:
|
|
320
|
+
# Restore each private file/directory
|
|
321
|
+
for file_path in private_files:
|
|
322
|
+
try:
|
|
323
|
+
if file_path.endswith('/'):
|
|
324
|
+
# Directory - use git archive
|
|
325
|
+
archive_cmd = [
|
|
326
|
+
'git', 'archive', private_commit,
|
|
327
|
+
'--format=tar', file_path
|
|
328
|
+
]
|
|
329
|
+
extract_cmd = ['tar', '-xf', '-']
|
|
330
|
+
|
|
331
|
+
archive = subprocess.Popen(
|
|
332
|
+
archive_cmd, stdout=subprocess.PIPE,
|
|
333
|
+
stderr=subprocess.PIPE, text=False
|
|
334
|
+
)
|
|
335
|
+
subprocess.run(
|
|
336
|
+
extract_cmd, stdin=archive.stdout,
|
|
337
|
+
check=True, stderr=subprocess.PIPE
|
|
338
|
+
)
|
|
339
|
+
archive.wait()
|
|
340
|
+
else:
|
|
341
|
+
# Single file - use git show
|
|
342
|
+
result = subprocess.run(
|
|
343
|
+
['git', 'show', f'{private_commit}:{file_path}'],
|
|
344
|
+
capture_output=True, text=True
|
|
345
|
+
)
|
|
346
|
+
if result.returncode == 0:
|
|
347
|
+
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
|
|
348
|
+
Path(file_path).write_text(result.stdout)
|
|
349
|
+
|
|
350
|
+
except subprocess.CalledProcessError:
|
|
351
|
+
# File might not exist in private branch
|
|
352
|
+
pass
|
|
353
|
+
|
|
354
|
+
# Update .gitignore to ensure private files are ignored
|
|
355
|
+
gitignore = Path('.gitignore')
|
|
356
|
+
if gitignore.exists():
|
|
357
|
+
content = gitignore.read_text()
|
|
358
|
+
|
|
359
|
+
# Add private patterns if not present
|
|
360
|
+
private_patterns = [
|
|
361
|
+
'\\n# RepoKit Private Content (DO NOT REMOVE)',
|
|
362
|
+
'CLAUDE.md',
|
|
363
|
+
'private/claude/',
|
|
364
|
+
'private/docs/',
|
|
365
|
+
'private/notes/',
|
|
366
|
+
'private/temp/',
|
|
367
|
+
]
|
|
368
|
+
|
|
369
|
+
needs_update = False
|
|
370
|
+
for pattern in private_patterns[1:]: # Skip comment
|
|
371
|
+
if pattern not in content:
|
|
372
|
+
needs_update = True
|
|
373
|
+
break
|
|
374
|
+
|
|
375
|
+
if needs_update:
|
|
376
|
+
# Add private section at the end
|
|
377
|
+
if not content.endswith('\\n'):
|
|
378
|
+
content += '\\n'
|
|
379
|
+
content += '\\n'.join(private_patterns) + '\\n'
|
|
380
|
+
gitignore.write_text(content)
|
|
381
|
+
print("✓ Updated .gitignore with private patterns")
|
|
382
|
+
|
|
383
|
+
print("✓ Private files restored for AI assistance")
|
|
384
|
+
print(" Note: These files are ignored and won't be committed")
|
|
385
|
+
|
|
386
|
+
except Exception as e:
|
|
387
|
+
print(f"⚠️ Could not restore private files: {e}")
|
|
388
|
+
print(" Run 'repokit restore-private' to restore manually")
|
|
389
|
+
|
|
390
|
+
elif context.is_private_branch():
|
|
391
|
+
# In private branch - ensure .gitignore doesn't exclude private files
|
|
392
|
+
gitignore = Path('.gitignore')
|
|
393
|
+
if gitignore.exists():
|
|
394
|
+
content = gitignore.read_text()
|
|
395
|
+
lines = content.split('\\n')
|
|
396
|
+
|
|
397
|
+
# Remove private file exclusions
|
|
398
|
+
private_patterns = ['CLAUDE.md', 'private/claude/', 'private/docs/', 'private/notes/', 'private/temp/']
|
|
399
|
+
filtered_lines = []
|
|
400
|
+
skip_next = False
|
|
401
|
+
|
|
402
|
+
for line in lines:
|
|
403
|
+
if '# RepoKit Private Content' in line:
|
|
404
|
+
skip_next = True
|
|
405
|
+
continue
|
|
406
|
+
if skip_next and line.strip() in private_patterns:
|
|
407
|
+
continue
|
|
408
|
+
if skip_next and line.strip() == '':
|
|
409
|
+
skip_next = False
|
|
410
|
+
continue
|
|
411
|
+
filtered_lines.append(line)
|
|
412
|
+
|
|
413
|
+
new_content = '\\n'.join(filtered_lines)
|
|
414
|
+
if new_content != content:
|
|
415
|
+
gitignore.write_text(new_content)
|
|
416
|
+
print("✓ Updated .gitignore for private branch")
|
|
417
|
+
|
|
418
|
+
except ImportError:
|
|
419
|
+
# RepoKit not installed, skip
|
|
420
|
+
pass
|
|
421
|
+
|
|
422
|
+
sys.exit(0)
|
|
423
|
+
EOF
|
|
424
|
+
'''
|
|
425
|
+
|
|
426
|
+
def check_status(self) -> Dict[str, any]:
|
|
427
|
+
"""Check current guardrails status."""
|
|
428
|
+
status = {
|
|
429
|
+
'branch': self.context.current_branch,
|
|
430
|
+
'branch_type': self.context.branch_type,
|
|
431
|
+
'pre_commit_hook': (self.hooks_dir / 'pre-commit').exists(),
|
|
432
|
+
'repokit_common_hooks': (self.hooks_dir / 'pre-commit').is_file() and
|
|
433
|
+
'repokit-common hook stub' in (self.hooks_dir / 'pre-commit').read_text(encoding='utf-8', errors='replace'),
|
|
434
|
+
'post_checkout_hook': (self.hooks_dir / 'post-checkout').exists(),
|
|
435
|
+
'excludes_configured': (self.git_dir / 'info' / 'exclude').exists(),
|
|
436
|
+
'staged_files': self.context.get_staged_files(),
|
|
437
|
+
'private_files_staged': [],
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
# Check for private files in staging
|
|
441
|
+
if status['staged_files']:
|
|
442
|
+
private_files = self.context.check_private_files(status['staged_files'])
|
|
443
|
+
status['private_files_staged'] = private_files
|
|
444
|
+
|
|
445
|
+
return status
|
|
446
|
+
|
|
447
|
+
def _print_status(self) -> None:
|
|
448
|
+
"""Print current guardrails status."""
|
|
449
|
+
status = self.check_status()
|
|
450
|
+
|
|
451
|
+
print("\n📊 RepoKit Guardrails Status:")
|
|
452
|
+
print(f" Current Branch: {status['branch']} ({status['branch_type']})")
|
|
453
|
+
print(f" Pre-commit Hook: {'✅' if status['pre_commit_hook'] else '❌'}"
|
|
454
|
+
f"{' (git-repokit-common)' if status['repokit_common_hooks'] else ''}")
|
|
455
|
+
print(f" Post-checkout Hook: {'✅' if status['post_checkout_hook'] else '❌'}")
|
|
456
|
+
print(f" Branch Excludes: {'✅' if status['excludes_configured'] else '❌'}")
|
|
457
|
+
|
|
458
|
+
if status['private_files_staged'] and status['branch_type'] == 'public':
|
|
459
|
+
print("\n⚠️ WARNING: Private files staged in public branch:")
|
|
460
|
+
for file, reason in status['private_files_staged']:
|
|
461
|
+
print(f" - {file}: {reason}")
|
|
462
|
+
|
|
463
|
+
def validate_merge(self, source_branch: str, target_branch: Optional[str] = None) -> bool:
|
|
464
|
+
"""
|
|
465
|
+
Validate if merge is safe regarding private content.
|
|
466
|
+
|
|
467
|
+
Args:
|
|
468
|
+
source_branch: Branch to merge from
|
|
469
|
+
target_branch: Branch to merge to (current if None)
|
|
470
|
+
|
|
471
|
+
Returns:
|
|
472
|
+
True if merge is safe, False otherwise
|
|
473
|
+
"""
|
|
474
|
+
if target_branch is None:
|
|
475
|
+
target_branch = self.context.current_branch
|
|
476
|
+
|
|
477
|
+
# Get excludes for this merge
|
|
478
|
+
excludes = self.context.get_merge_excludes(source_branch, target_branch)
|
|
479
|
+
|
|
480
|
+
if excludes:
|
|
481
|
+
logger.warning(f"⚠️ Merging from '{source_branch}' to '{target_branch}'")
|
|
482
|
+
logger.warning("The following files will be excluded:")
|
|
483
|
+
for exclude in sorted(excludes):
|
|
484
|
+
logger.warning(f" - {exclude}")
|
|
485
|
+
|
|
486
|
+
return True
|
|
487
|
+
|
|
488
|
+
return True
|
|
489
|
+
|
|
490
|
+
def safe_merge(self, source_branch: str, no_commit: bool = True,
|
|
491
|
+
no_ff: bool = True, preview: bool = False) -> bool:
|
|
492
|
+
"""
|
|
493
|
+
Perform a safe merge that respects private content rules.
|
|
494
|
+
|
|
495
|
+
Args:
|
|
496
|
+
source_branch: Branch to merge from
|
|
497
|
+
no_commit: Use --no-commit flag
|
|
498
|
+
no_ff: Use --no-ff flag
|
|
499
|
+
preview: Only show what would be merged
|
|
500
|
+
|
|
501
|
+
Returns:
|
|
502
|
+
True if successful, False otherwise
|
|
503
|
+
"""
|
|
504
|
+
target_branch = self.context.current_branch
|
|
505
|
+
|
|
506
|
+
# Validate merge
|
|
507
|
+
if not self.validate_merge(source_branch, target_branch):
|
|
508
|
+
return False
|
|
509
|
+
|
|
510
|
+
# Get files to exclude
|
|
511
|
+
excludes = self.context.get_merge_excludes(source_branch, target_branch)
|
|
512
|
+
|
|
513
|
+
if preview:
|
|
514
|
+
print(f"\n🔍 Preview: Merge '{source_branch}' → '{target_branch}'")
|
|
515
|
+
|
|
516
|
+
# Show commits that would be merged
|
|
517
|
+
result = subprocess.run(
|
|
518
|
+
['git', 'log', '--oneline', f'{target_branch}..{source_branch}'],
|
|
519
|
+
capture_output=True, text=True
|
|
520
|
+
)
|
|
521
|
+
print("\nCommits to merge:")
|
|
522
|
+
print(result.stdout)
|
|
523
|
+
|
|
524
|
+
if excludes:
|
|
525
|
+
print("\nFiles that will be excluded:")
|
|
526
|
+
for exclude in sorted(excludes):
|
|
527
|
+
print(f" - {exclude}")
|
|
528
|
+
|
|
529
|
+
return True
|
|
530
|
+
|
|
531
|
+
# Perform merge
|
|
532
|
+
merge_args = ['git', 'merge', source_branch]
|
|
533
|
+
if no_ff:
|
|
534
|
+
merge_args.append('--no-ff')
|
|
535
|
+
if no_commit:
|
|
536
|
+
merge_args.append('--no-commit')
|
|
537
|
+
|
|
538
|
+
logger.info(f"Merging '{source_branch}' → '{target_branch}'...")
|
|
539
|
+
result = subprocess.run(merge_args, capture_output=True, text=True)
|
|
540
|
+
|
|
541
|
+
if result.returncode != 0:
|
|
542
|
+
logger.error(f"Merge failed: {result.stderr}")
|
|
543
|
+
return False
|
|
544
|
+
|
|
545
|
+
# If we have excludes and merge succeeded, remove excluded files
|
|
546
|
+
if excludes and no_commit:
|
|
547
|
+
logger.info("Removing excluded files from merge...")
|
|
548
|
+
for exclude in excludes:
|
|
549
|
+
try:
|
|
550
|
+
subprocess.run(['git', 'rm', '-rf', '--ignore-unmatch', exclude],
|
|
551
|
+
check=True, capture_output=True, text=True)
|
|
552
|
+
except subprocess.CalledProcessError:
|
|
553
|
+
pass # File might not exist
|
|
554
|
+
|
|
555
|
+
print("\n✅ Safe merge completed. Excluded files have been removed.")
|
|
556
|
+
print("Review changes and commit when ready.")
|
|
557
|
+
|
|
558
|
+
return True
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
def setup_guardrails_command(args) -> int:
|
|
562
|
+
"""CLI command to set up guardrails.
|
|
563
|
+
|
|
564
|
+
By default the hooks are git-repokit-common's (djdarcy, 2026-10-08: "we
|
|
565
|
+
should switch it to repokit-common hooks as all future projects should be
|
|
566
|
+
using all of our tools properly"). --legacy keeps git-repokit's previous
|
|
567
|
+
hooks available.
|
|
568
|
+
"""
|
|
569
|
+
manager = GuardrailsManager()
|
|
570
|
+
|
|
571
|
+
if getattr(args, "legacy", False):
|
|
572
|
+
return 0 if manager.setup_guardrails(force=args.force) else 1
|
|
573
|
+
return manager.setup_repokit_common(vendor=getattr(args, "vendor", False))
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def check_guardrails_command(args) -> int:
|
|
577
|
+
"""CLI command to check guardrails status."""
|
|
578
|
+
manager = GuardrailsManager()
|
|
579
|
+
manager._print_status()
|
|
580
|
+
|
|
581
|
+
# Run validation
|
|
582
|
+
context = BranchContext()
|
|
583
|
+
is_valid, errors = context.validate_commit()
|
|
584
|
+
|
|
585
|
+
if not is_valid:
|
|
586
|
+
print("\n❌ Current state would fail pre-commit check!")
|
|
587
|
+
return 1
|
|
588
|
+
|
|
589
|
+
print("\n✅ Current state passes all checks!")
|
|
590
|
+
return 0
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
def restore_private_files() -> bool:
|
|
594
|
+
"""Restore private files from private branch to current branch."""
|
|
595
|
+
try:
|
|
596
|
+
# Get current branch
|
|
597
|
+
result = subprocess.run(
|
|
598
|
+
['git', 'rev-parse', '--abbrev-ref', 'HEAD'],
|
|
599
|
+
capture_output=True, text=True
|
|
600
|
+
)
|
|
601
|
+
current_branch = result.stdout.strip()
|
|
602
|
+
|
|
603
|
+
if current_branch == 'private':
|
|
604
|
+
print("Already on private branch - files should be present.")
|
|
605
|
+
return True
|
|
606
|
+
|
|
607
|
+
print(f"Restoring private files to '{current_branch}' branch...")
|
|
608
|
+
|
|
609
|
+
# Get private branch commit
|
|
610
|
+
result = subprocess.run(
|
|
611
|
+
['git', 'rev-parse', 'private'],
|
|
612
|
+
capture_output=True, text=True
|
|
613
|
+
)
|
|
614
|
+
|
|
615
|
+
if result.returncode != 0:
|
|
616
|
+
print("❌ Private branch not found!")
|
|
617
|
+
return False
|
|
618
|
+
|
|
619
|
+
private_commit = result.stdout.strip()
|
|
620
|
+
|
|
621
|
+
# Files to restore
|
|
622
|
+
files_to_restore = [
|
|
623
|
+
('CLAUDE.md', False),
|
|
624
|
+
('private/claude/', True),
|
|
625
|
+
('private/docs/', True),
|
|
626
|
+
]
|
|
627
|
+
|
|
628
|
+
restored_count = 0
|
|
629
|
+
for file_path, is_dir in files_to_restore:
|
|
630
|
+
try:
|
|
631
|
+
if is_dir:
|
|
632
|
+
# Use git archive for directories
|
|
633
|
+
print(f" Restoring {file_path}...")
|
|
634
|
+
archive_cmd = ['git', 'archive', private_commit, '--format=tar', file_path]
|
|
635
|
+
extract_cmd = ['tar', '-xf', '-']
|
|
636
|
+
|
|
637
|
+
archive = subprocess.Popen(archive_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=False)
|
|
638
|
+
extract = subprocess.run(extract_cmd, stdin=archive.stdout, capture_output=True, text=False)
|
|
639
|
+
archive.wait()
|
|
640
|
+
|
|
641
|
+
if archive.returncode == 0:
|
|
642
|
+
restored_count += 1
|
|
643
|
+
else:
|
|
644
|
+
# Use git show for single files
|
|
645
|
+
result = subprocess.run(
|
|
646
|
+
['git', 'show', f'{private_commit}:{file_path}'],
|
|
647
|
+
capture_output=True, text=True
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
if result.returncode == 0:
|
|
651
|
+
Path(file_path).parent.mkdir(parents=True, exist_ok=True)
|
|
652
|
+
Path(file_path).write_text(result.stdout)
|
|
653
|
+
print(f" Restored {file_path}")
|
|
654
|
+
restored_count += 1
|
|
655
|
+
|
|
656
|
+
except Exception as e:
|
|
657
|
+
print(f" ⚠️ Could not restore {file_path}: {e}")
|
|
658
|
+
|
|
659
|
+
print(f"\n✅ Restored {restored_count} private file(s)/folder(s)")
|
|
660
|
+
print("Note: These files are ignored by git and won't be committed")
|
|
661
|
+
|
|
662
|
+
return True
|
|
663
|
+
|
|
664
|
+
except Exception as e:
|
|
665
|
+
print(f"❌ Error restoring private files: {e}")
|
|
666
|
+
return False
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def sync_private_files() -> bool:
|
|
670
|
+
"""Sync private file changes back to private branch."""
|
|
671
|
+
try:
|
|
672
|
+
context = BranchContext()
|
|
673
|
+
|
|
674
|
+
if context.is_private_branch():
|
|
675
|
+
print("Already on private branch - use git add/commit directly.")
|
|
676
|
+
return True
|
|
677
|
+
|
|
678
|
+
print("Syncing private file changes to private branch...")
|
|
679
|
+
|
|
680
|
+
# Stash current changes
|
|
681
|
+
print("1. Stashing current changes...")
|
|
682
|
+
subprocess.run(['git', 'stash', 'push', '-m', 'repokit-sync-private'], check=True, capture_output=True, text=True)
|
|
683
|
+
|
|
684
|
+
# Switch to private branch
|
|
685
|
+
print("2. Switching to private branch...")
|
|
686
|
+
subprocess.run(['git', 'checkout', 'private'], check=True, capture_output=True, text=True)
|
|
687
|
+
|
|
688
|
+
# Apply stash
|
|
689
|
+
print("3. Applying changes...")
|
|
690
|
+
result = subprocess.run(['git', 'stash', 'pop'], capture_output=True, text=True)
|
|
691
|
+
|
|
692
|
+
if result.returncode != 0:
|
|
693
|
+
print("⚠️ Some conflicts occurred. Please resolve manually.")
|
|
694
|
+
return False
|
|
695
|
+
|
|
696
|
+
print("\n✅ Changes synced to private branch")
|
|
697
|
+
print("Next steps:")
|
|
698
|
+
print(" 1. Review changes: git status")
|
|
699
|
+
print(" 2. Add files: git add <files>")
|
|
700
|
+
print(" 3. Commit: git commit -m 'your message'")
|
|
701
|
+
print(" 4. Return to previous branch: git checkout -")
|
|
702
|
+
|
|
703
|
+
return True
|
|
704
|
+
|
|
705
|
+
except Exception as e:
|
|
706
|
+
print(f"❌ Error syncing to private branch: {e}")
|
|
707
|
+
return False
|