itcpr 2.0.4__tar.gz → 2.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.
- itcpr-2.0.7/LICENSE +22 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/PKG-INFO +59 -2
- {itcpr-2.0.4 → itcpr-2.0.7}/README.md +53 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/__init__.py +1 -1
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/cli.py +16 -5
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/sync.py +96 -23
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/PKG-INFO +59 -2
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/SOURCES.txt +1 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/requires.txt +3 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/pyproject.toml +2 -1
- {itcpr-2.0.4 → itcpr-2.0.7}/setup.py +4 -3
- {itcpr-2.0.4 → itcpr-2.0.7}/MANIFEST.in +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/api.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/auth.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/config.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/gitops.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/storage.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr/utils.py +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/dependency_links.txt +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/entry_points.txt +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/itcpr.egg-info/top_level.txt +0 -0
- {itcpr-2.0.4 → itcpr-2.0.7}/setup.cfg +0 -0
itcpr-2.0.7/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 ITCPR
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itcpr
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.7
|
|
4
4
|
Summary: CLI tool for syncing GitHub repositories from ITCPR Cloud
|
|
5
|
-
Home-page: https://
|
|
5
|
+
Home-page: https://itcpr.org
|
|
6
6
|
Author: ITCPR
|
|
7
7
|
Author-email: ITCPR <info@itcpr.org>
|
|
8
8
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
19
20
|
Requires-Dist: click>=8.0.0
|
|
20
21
|
Requires-Dist: requests>=2.28.0
|
|
21
22
|
Requires-Dist: keyring>=23.0.0
|
|
@@ -24,8 +25,11 @@ Provides-Extra: dev
|
|
|
24
25
|
Requires-Dist: pytest; extra == "dev"
|
|
25
26
|
Requires-Dist: black; extra == "dev"
|
|
26
27
|
Requires-Dist: flake8; extra == "dev"
|
|
28
|
+
Provides-Extra: yaml
|
|
29
|
+
Requires-Dist: PyYAML>=6.0; extra == "yaml"
|
|
27
30
|
Dynamic: author
|
|
28
31
|
Dynamic: home-page
|
|
32
|
+
Dynamic: license-file
|
|
29
33
|
Dynamic: requires-python
|
|
30
34
|
|
|
31
35
|
# ITCPR CLI
|
|
@@ -216,6 +220,23 @@ Options:
|
|
|
216
220
|
- `--watch, -w`: Run continuous sync loop
|
|
217
221
|
- `--interval, -i`: Sync interval in seconds (watch mode only, default: 60)
|
|
218
222
|
|
|
223
|
+
**Sync Rules (itcpr.yml):**
|
|
224
|
+
|
|
225
|
+
You can configure per-repository sync behavior by creating an `itcpr.yml` file in the repository root:
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
sync:
|
|
229
|
+
enabled: true # Enable/disable sync for this repo (default: true)
|
|
230
|
+
auto_commit: true # Auto-commit local changes (default: true)
|
|
231
|
+
auto_push: true # Auto-push local commits (default: true)
|
|
232
|
+
branch: main # Optional: specific branch to sync
|
|
233
|
+
ignore: # Optional: patterns to ignore
|
|
234
|
+
- "*.log"
|
|
235
|
+
- "temp/"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Note:** To use `itcpr.yml`, install PyYAML: `pip install itcpr[yaml]` or `pip install PyYAML`
|
|
239
|
+
|
|
219
240
|
## How It Works
|
|
220
241
|
|
|
221
242
|
### Authentication
|
|
@@ -243,10 +264,46 @@ Options:
|
|
|
243
264
|
|
|
244
265
|
## Configuration
|
|
245
266
|
|
|
267
|
+
### Global Configuration
|
|
268
|
+
|
|
246
269
|
Configuration is stored in `~/.itcpr/config.toml`.
|
|
247
270
|
|
|
248
271
|
Repository metadata is stored in `~/.itcpr/repos.db` (SQLite).
|
|
249
272
|
|
|
273
|
+
### Per-Repository Configuration (itcpr.yml)
|
|
274
|
+
|
|
275
|
+
Each repository can have its own `itcpr.yml` file in the repository root to control sync behavior:
|
|
276
|
+
|
|
277
|
+
```yaml
|
|
278
|
+
sync:
|
|
279
|
+
enabled: true # Enable/disable sync for this repo
|
|
280
|
+
auto_commit: true # Automatically commit local changes
|
|
281
|
+
auto_push: true # Automatically push local commits
|
|
282
|
+
branch: main # Optional: sync specific branch
|
|
283
|
+
ignore: [] # Optional: file patterns to ignore
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Example: Disable auto-push for a repository**
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
sync:
|
|
290
|
+
auto_push: false
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Example: Disable sync entirely for a repository**
|
|
294
|
+
|
|
295
|
+
```yaml
|
|
296
|
+
sync:
|
|
297
|
+
enabled: false
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Installation:** To use `itcpr.yml` files, install the optional YAML dependency:
|
|
301
|
+
```bash
|
|
302
|
+
pip install itcpr[yaml]
|
|
303
|
+
# OR
|
|
304
|
+
pip install PyYAML
|
|
305
|
+
```
|
|
306
|
+
|
|
250
307
|
## Troubleshooting
|
|
251
308
|
|
|
252
309
|
### "Not logged in" error
|
|
@@ -186,6 +186,23 @@ Options:
|
|
|
186
186
|
- `--watch, -w`: Run continuous sync loop
|
|
187
187
|
- `--interval, -i`: Sync interval in seconds (watch mode only, default: 60)
|
|
188
188
|
|
|
189
|
+
**Sync Rules (itcpr.yml):**
|
|
190
|
+
|
|
191
|
+
You can configure per-repository sync behavior by creating an `itcpr.yml` file in the repository root:
|
|
192
|
+
|
|
193
|
+
```yaml
|
|
194
|
+
sync:
|
|
195
|
+
enabled: true # Enable/disable sync for this repo (default: true)
|
|
196
|
+
auto_commit: true # Auto-commit local changes (default: true)
|
|
197
|
+
auto_push: true # Auto-push local commits (default: true)
|
|
198
|
+
branch: main # Optional: specific branch to sync
|
|
199
|
+
ignore: # Optional: patterns to ignore
|
|
200
|
+
- "*.log"
|
|
201
|
+
- "temp/"
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Note:** To use `itcpr.yml`, install PyYAML: `pip install itcpr[yaml]` or `pip install PyYAML`
|
|
205
|
+
|
|
189
206
|
## How It Works
|
|
190
207
|
|
|
191
208
|
### Authentication
|
|
@@ -213,10 +230,46 @@ Options:
|
|
|
213
230
|
|
|
214
231
|
## Configuration
|
|
215
232
|
|
|
233
|
+
### Global Configuration
|
|
234
|
+
|
|
216
235
|
Configuration is stored in `~/.itcpr/config.toml`.
|
|
217
236
|
|
|
218
237
|
Repository metadata is stored in `~/.itcpr/repos.db` (SQLite).
|
|
219
238
|
|
|
239
|
+
### Per-Repository Configuration (itcpr.yml)
|
|
240
|
+
|
|
241
|
+
Each repository can have its own `itcpr.yml` file in the repository root to control sync behavior:
|
|
242
|
+
|
|
243
|
+
```yaml
|
|
244
|
+
sync:
|
|
245
|
+
enabled: true # Enable/disable sync for this repo
|
|
246
|
+
auto_commit: true # Automatically commit local changes
|
|
247
|
+
auto_push: true # Automatically push local commits
|
|
248
|
+
branch: main # Optional: sync specific branch
|
|
249
|
+
ignore: [] # Optional: file patterns to ignore
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Example: Disable auto-push for a repository**
|
|
253
|
+
|
|
254
|
+
```yaml
|
|
255
|
+
sync:
|
|
256
|
+
auto_push: false
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Example: Disable sync entirely for a repository**
|
|
260
|
+
|
|
261
|
+
```yaml
|
|
262
|
+
sync:
|
|
263
|
+
enabled: false
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**Installation:** To use `itcpr.yml` files, install the optional YAML dependency:
|
|
267
|
+
```bash
|
|
268
|
+
pip install itcpr[yaml]
|
|
269
|
+
# OR
|
|
270
|
+
pip install PyYAML
|
|
271
|
+
```
|
|
272
|
+
|
|
220
273
|
## Troubleshooting
|
|
221
274
|
|
|
222
275
|
### "Not logged in" error
|
|
@@ -2,11 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import click
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from .auth import Auth
|
|
6
|
-
from .api import APIClient
|
|
7
|
-
from .storage import Storage
|
|
8
|
-
from .sync import SyncManager
|
|
9
|
-
from .gitops import GitOps
|
|
10
5
|
from .utils import setup_logging, print_error, print_success, print_info, get_logger
|
|
11
6
|
|
|
12
7
|
logger = get_logger(__name__)
|
|
@@ -23,6 +18,7 @@ def cli(ctx, verbose):
|
|
|
23
18
|
@cli.command()
|
|
24
19
|
def login():
|
|
25
20
|
"""Authenticate this device with cloud.itcpr.org."""
|
|
21
|
+
from .auth import Auth
|
|
26
22
|
auth = Auth()
|
|
27
23
|
if auth.is_authenticated():
|
|
28
24
|
if not click.confirm("You are already logged in. Do you want to login again?"):
|
|
@@ -36,6 +32,7 @@ def login():
|
|
|
36
32
|
@cli.command()
|
|
37
33
|
def logout():
|
|
38
34
|
"""Logout and clear stored credentials."""
|
|
35
|
+
from .auth import Auth
|
|
39
36
|
auth = Auth()
|
|
40
37
|
if not auth.is_authenticated():
|
|
41
38
|
click.echo("Not logged in.")
|
|
@@ -47,6 +44,9 @@ def logout():
|
|
|
47
44
|
@click.pass_context
|
|
48
45
|
def status(ctx):
|
|
49
46
|
"""Show current status and assigned repositories."""
|
|
47
|
+
from .auth import Auth
|
|
48
|
+
from .api import APIClient
|
|
49
|
+
from .storage import Storage
|
|
50
50
|
auth = Auth()
|
|
51
51
|
if not auth.is_authenticated():
|
|
52
52
|
click.echo("Not logged in. Run 'itcpr login' first.")
|
|
@@ -100,6 +100,9 @@ def status(ctx):
|
|
|
100
100
|
@click.pass_context
|
|
101
101
|
def repos(ctx):
|
|
102
102
|
"""List assigned repositories and their sync status."""
|
|
103
|
+
from .auth import Auth
|
|
104
|
+
from .api import APIClient
|
|
105
|
+
from .storage import Storage
|
|
103
106
|
auth = Auth()
|
|
104
107
|
if not auth.is_authenticated():
|
|
105
108
|
click.echo("Not logged in. Run 'itcpr login' first.")
|
|
@@ -148,6 +151,10 @@ def repos(ctx):
|
|
|
148
151
|
@click.pass_context
|
|
149
152
|
def clone(ctx, repo, path):
|
|
150
153
|
"""Clone a repository from GitHub."""
|
|
154
|
+
from .auth import Auth
|
|
155
|
+
from .api import APIClient
|
|
156
|
+
from .storage import Storage
|
|
157
|
+
from .gitops import GitOps
|
|
151
158
|
auth = Auth()
|
|
152
159
|
if not auth.is_authenticated():
|
|
153
160
|
click.echo("Not logged in. Run 'itcpr login' first.")
|
|
@@ -219,6 +226,10 @@ def clone(ctx, repo, path):
|
|
|
219
226
|
@click.pass_context
|
|
220
227
|
def sync(ctx, watch, interval):
|
|
221
228
|
"""Sync repositories with remote."""
|
|
229
|
+
from .auth import Auth
|
|
230
|
+
from .api import APIClient
|
|
231
|
+
from .storage import Storage
|
|
232
|
+
from .sync import SyncManager
|
|
222
233
|
auth = Auth()
|
|
223
234
|
if not auth.is_authenticated():
|
|
224
235
|
click.echo("Not logged in. Run 'itcpr login' first.")
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import time
|
|
4
4
|
import signal
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import Optional, Dict, Any
|
|
6
|
+
from typing import Optional, Dict, Any, List
|
|
7
7
|
from .gitops import GitOps
|
|
8
8
|
from .api import APIClient
|
|
9
9
|
from .storage import Storage
|
|
@@ -11,6 +11,44 @@ from .utils import get_logger, print_error, print_success, print_info
|
|
|
11
11
|
|
|
12
12
|
logger = get_logger(__name__)
|
|
13
13
|
|
|
14
|
+
# Try to import yaml, but make it optional
|
|
15
|
+
try:
|
|
16
|
+
import yaml
|
|
17
|
+
YAML_AVAILABLE = True
|
|
18
|
+
except ImportError:
|
|
19
|
+
YAML_AVAILABLE = False
|
|
20
|
+
yaml = None
|
|
21
|
+
|
|
22
|
+
def load_sync_rules(repo_path: Path) -> Dict[str, Any]:
|
|
23
|
+
"""Load sync rules from itcpr.yml in repository root."""
|
|
24
|
+
config_file = repo_path / "itcpr.yml"
|
|
25
|
+
|
|
26
|
+
if not config_file.exists():
|
|
27
|
+
return {}
|
|
28
|
+
|
|
29
|
+
if not YAML_AVAILABLE:
|
|
30
|
+
logger.warning("YAML not available. Install PyYAML to use itcpr.yml configuration.")
|
|
31
|
+
return {}
|
|
32
|
+
|
|
33
|
+
try:
|
|
34
|
+
with open(config_file, 'r', encoding='utf-8') as f:
|
|
35
|
+
config = yaml.safe_load(f)
|
|
36
|
+
if not isinstance(config, dict):
|
|
37
|
+
return {}
|
|
38
|
+
|
|
39
|
+
# Extract sync rules
|
|
40
|
+
sync_config = config.get('sync', {})
|
|
41
|
+
return {
|
|
42
|
+
'enabled': sync_config.get('enabled', True),
|
|
43
|
+
'auto_commit': sync_config.get('auto_commit', True),
|
|
44
|
+
'auto_push': sync_config.get('auto_push', True),
|
|
45
|
+
'branch': sync_config.get('branch'),
|
|
46
|
+
'ignore_patterns': sync_config.get('ignore', []),
|
|
47
|
+
}
|
|
48
|
+
except Exception as e:
|
|
49
|
+
logger.warning(f"Failed to load itcpr.yml from {repo_path}: {e}")
|
|
50
|
+
return {}
|
|
51
|
+
|
|
14
52
|
class SyncManager:
|
|
15
53
|
"""Manages repository synchronization."""
|
|
16
54
|
|
|
@@ -25,6 +63,18 @@ class SyncManager:
|
|
|
25
63
|
logger.info(f"Syncing repository: {repo_name}")
|
|
26
64
|
|
|
27
65
|
try:
|
|
66
|
+
# Load sync rules from itcpr.yml
|
|
67
|
+
rules = load_sync_rules(repo_path)
|
|
68
|
+
|
|
69
|
+
# Check if sync is disabled for this repo
|
|
70
|
+
if not rules.get('enabled', True):
|
|
71
|
+
logger.info(f"Sync disabled for {repo_name} (itcpr.yml)")
|
|
72
|
+
return {
|
|
73
|
+
"success": True,
|
|
74
|
+
"skipped": True,
|
|
75
|
+
"message": "Sync disabled in itcpr.yml"
|
|
76
|
+
}
|
|
77
|
+
|
|
28
78
|
git = GitOps(repo_path)
|
|
29
79
|
|
|
30
80
|
if not git.is_repo():
|
|
@@ -33,19 +83,33 @@ class SyncManager:
|
|
|
33
83
|
"error": f"Not a git repository: {repo_path}"
|
|
34
84
|
}
|
|
35
85
|
|
|
86
|
+
# Check if we need to switch branch
|
|
87
|
+
if rules.get('branch'):
|
|
88
|
+
current_branch = git.get_current_branch()
|
|
89
|
+
if current_branch != rules['branch']:
|
|
90
|
+
logger.info(f"Switching to branch {rules['branch']} for {repo_name}")
|
|
91
|
+
# Note: Branch switching would need to be implemented in GitOps if needed
|
|
92
|
+
|
|
36
93
|
# Check status
|
|
37
94
|
status = git.get_status()
|
|
38
95
|
if not status.get("clean"):
|
|
39
96
|
if status.get("has_changes"):
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
97
|
+
# Check if auto_commit is enabled (default: True)
|
|
98
|
+
if rules.get('auto_commit', True):
|
|
99
|
+
print_info(f" Uncommitted changes detected in {repo_name}")
|
|
100
|
+
# Commit local changes
|
|
101
|
+
try:
|
|
102
|
+
git.commit_if_changes()
|
|
103
|
+
print_success(f" Committed local changes")
|
|
104
|
+
except Exception as e:
|
|
105
|
+
return {
|
|
106
|
+
"success": False,
|
|
107
|
+
"error": f"Failed to commit changes: {e}"
|
|
108
|
+
}
|
|
109
|
+
else:
|
|
46
110
|
return {
|
|
47
111
|
"success": False,
|
|
48
|
-
"error":
|
|
112
|
+
"error": "Uncommitted changes detected and auto_commit is disabled in itcpr.yml"
|
|
49
113
|
}
|
|
50
114
|
|
|
51
115
|
# Fetch latest
|
|
@@ -68,17 +132,21 @@ class SyncManager:
|
|
|
68
132
|
}
|
|
69
133
|
raise
|
|
70
134
|
|
|
71
|
-
# Push if ahead
|
|
135
|
+
# Push if ahead (check auto_push rule)
|
|
72
136
|
if status.get("ahead"):
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
137
|
+
if rules.get('auto_push', True):
|
|
138
|
+
print_info(f" Pushing local commits...")
|
|
139
|
+
try:
|
|
140
|
+
git.push()
|
|
141
|
+
print_success(f" Pushed local commits")
|
|
142
|
+
except Exception as e:
|
|
143
|
+
return {
|
|
144
|
+
"success": False,
|
|
145
|
+
"error": f"Failed to push: {e}"
|
|
146
|
+
}
|
|
147
|
+
else:
|
|
148
|
+
logger.info(f"Push skipped for {repo_name} (auto_push disabled in itcpr.yml)")
|
|
149
|
+
print_info(f" Local commits not pushed (auto_push disabled)")
|
|
82
150
|
|
|
83
151
|
# Update sync time
|
|
84
152
|
self.storage.update_sync_time(repo_name)
|
|
@@ -96,17 +164,18 @@ class SyncManager:
|
|
|
96
164
|
}
|
|
97
165
|
|
|
98
166
|
def sync_all(self) -> Dict[str, Any]:
|
|
99
|
-
"""Sync all tracked repositories."""
|
|
167
|
+
"""Sync all tracked repositories, respecting itcpr.yml rules."""
|
|
100
168
|
repos = self.storage.list_repos()
|
|
101
169
|
|
|
102
170
|
if not repos:
|
|
103
171
|
print_info("No repositories to sync")
|
|
104
|
-
return {"success": True, "synced": 0, "failed": 0}
|
|
172
|
+
return {"success": True, "synced": 0, "failed": 0, "skipped": 0}
|
|
105
173
|
|
|
106
174
|
print_info(f"Syncing {len(repos)} repositories...")
|
|
107
175
|
|
|
108
176
|
synced = 0
|
|
109
177
|
failed = 0
|
|
178
|
+
skipped = 0
|
|
110
179
|
|
|
111
180
|
for repo in repos:
|
|
112
181
|
repo_path = Path(repo["local_path"])
|
|
@@ -117,17 +186,21 @@ class SyncManager:
|
|
|
117
186
|
|
|
118
187
|
result = self.sync_repo(repo["name"], repo_path)
|
|
119
188
|
if result.get("success"):
|
|
120
|
-
|
|
189
|
+
if result.get("skipped"):
|
|
190
|
+
skipped += 1
|
|
191
|
+
else:
|
|
192
|
+
synced += 1
|
|
121
193
|
else:
|
|
122
194
|
failed += 1
|
|
123
195
|
if result.get("error"):
|
|
124
196
|
print_error(f" {result['error']}")
|
|
125
197
|
|
|
126
|
-
print_info(f"\nSync complete: {synced} succeeded, {failed} failed")
|
|
198
|
+
print_info(f"\nSync complete: {synced} succeeded, {failed} failed, {skipped} skipped")
|
|
127
199
|
return {
|
|
128
200
|
"success": failed == 0,
|
|
129
201
|
"synced": synced,
|
|
130
|
-
"failed": failed
|
|
202
|
+
"failed": failed,
|
|
203
|
+
"skipped": skipped
|
|
131
204
|
}
|
|
132
205
|
|
|
133
206
|
def watch(self, interval: int = 60):
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itcpr
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.7
|
|
4
4
|
Summary: CLI tool for syncing GitHub repositories from ITCPR Cloud
|
|
5
|
-
Home-page: https://
|
|
5
|
+
Home-page: https://itcpr.org
|
|
6
6
|
Author: ITCPR
|
|
7
7
|
Author-email: ITCPR <info@itcpr.org>
|
|
8
8
|
License: MIT
|
|
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.12
|
|
17
17
|
Requires-Python: >=3.10
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
19
20
|
Requires-Dist: click>=8.0.0
|
|
20
21
|
Requires-Dist: requests>=2.28.0
|
|
21
22
|
Requires-Dist: keyring>=23.0.0
|
|
@@ -24,8 +25,11 @@ Provides-Extra: dev
|
|
|
24
25
|
Requires-Dist: pytest; extra == "dev"
|
|
25
26
|
Requires-Dist: black; extra == "dev"
|
|
26
27
|
Requires-Dist: flake8; extra == "dev"
|
|
28
|
+
Provides-Extra: yaml
|
|
29
|
+
Requires-Dist: PyYAML>=6.0; extra == "yaml"
|
|
27
30
|
Dynamic: author
|
|
28
31
|
Dynamic: home-page
|
|
32
|
+
Dynamic: license-file
|
|
29
33
|
Dynamic: requires-python
|
|
30
34
|
|
|
31
35
|
# ITCPR CLI
|
|
@@ -216,6 +220,23 @@ Options:
|
|
|
216
220
|
- `--watch, -w`: Run continuous sync loop
|
|
217
221
|
- `--interval, -i`: Sync interval in seconds (watch mode only, default: 60)
|
|
218
222
|
|
|
223
|
+
**Sync Rules (itcpr.yml):**
|
|
224
|
+
|
|
225
|
+
You can configure per-repository sync behavior by creating an `itcpr.yml` file in the repository root:
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
sync:
|
|
229
|
+
enabled: true # Enable/disable sync for this repo (default: true)
|
|
230
|
+
auto_commit: true # Auto-commit local changes (default: true)
|
|
231
|
+
auto_push: true # Auto-push local commits (default: true)
|
|
232
|
+
branch: main # Optional: specific branch to sync
|
|
233
|
+
ignore: # Optional: patterns to ignore
|
|
234
|
+
- "*.log"
|
|
235
|
+
- "temp/"
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Note:** To use `itcpr.yml`, install PyYAML: `pip install itcpr[yaml]` or `pip install PyYAML`
|
|
239
|
+
|
|
219
240
|
## How It Works
|
|
220
241
|
|
|
221
242
|
### Authentication
|
|
@@ -243,10 +264,46 @@ Options:
|
|
|
243
264
|
|
|
244
265
|
## Configuration
|
|
245
266
|
|
|
267
|
+
### Global Configuration
|
|
268
|
+
|
|
246
269
|
Configuration is stored in `~/.itcpr/config.toml`.
|
|
247
270
|
|
|
248
271
|
Repository metadata is stored in `~/.itcpr/repos.db` (SQLite).
|
|
249
272
|
|
|
273
|
+
### Per-Repository Configuration (itcpr.yml)
|
|
274
|
+
|
|
275
|
+
Each repository can have its own `itcpr.yml` file in the repository root to control sync behavior:
|
|
276
|
+
|
|
277
|
+
```yaml
|
|
278
|
+
sync:
|
|
279
|
+
enabled: true # Enable/disable sync for this repo
|
|
280
|
+
auto_commit: true # Automatically commit local changes
|
|
281
|
+
auto_push: true # Automatically push local commits
|
|
282
|
+
branch: main # Optional: sync specific branch
|
|
283
|
+
ignore: [] # Optional: file patterns to ignore
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Example: Disable auto-push for a repository**
|
|
287
|
+
|
|
288
|
+
```yaml
|
|
289
|
+
sync:
|
|
290
|
+
auto_push: false
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**Example: Disable sync entirely for a repository**
|
|
294
|
+
|
|
295
|
+
```yaml
|
|
296
|
+
sync:
|
|
297
|
+
enabled: false
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Installation:** To use `itcpr.yml` files, install the optional YAML dependency:
|
|
301
|
+
```bash
|
|
302
|
+
pip install itcpr[yaml]
|
|
303
|
+
# OR
|
|
304
|
+
pip install PyYAML
|
|
305
|
+
```
|
|
306
|
+
|
|
250
307
|
## Troubleshooting
|
|
251
308
|
|
|
252
309
|
### "Not logged in" error
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "itcpr"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.7"
|
|
8
8
|
description = "CLI tool for syncing GitHub repositories from ITCPR Cloud"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -34,6 +34,7 @@ itcpr = "itcpr.cli:main"
|
|
|
34
34
|
|
|
35
35
|
[project.optional-dependencies]
|
|
36
36
|
dev = ["pytest", "black", "flake8"]
|
|
37
|
+
yaml = ["PyYAML>=6.0"] # For itcpr.yml support
|
|
37
38
|
|
|
38
39
|
[tool.setuptools]
|
|
39
40
|
packages = ["itcpr"]
|
|
@@ -9,13 +9,13 @@ long_description = readme_file.read_text() if readme_file.exists() else ""
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name="itcpr",
|
|
12
|
-
version="2.0.
|
|
12
|
+
version="2.0.7",
|
|
13
13
|
description="CLI tool for syncing GitHub repositories from ITCPR Cloud",
|
|
14
14
|
long_description=long_description,
|
|
15
15
|
long_description_content_type="text/markdown",
|
|
16
16
|
author="ITCPR",
|
|
17
17
|
author_email="info@itcpr.org",
|
|
18
|
-
url="https://
|
|
18
|
+
url="https://itcpr.org",
|
|
19
19
|
packages=find_packages(),
|
|
20
20
|
python_requires=">=3.10",
|
|
21
21
|
install_requires=[
|
|
@@ -24,9 +24,10 @@ setup(
|
|
|
24
24
|
"keyring>=23.0.0",
|
|
25
25
|
"tomli-w>=1.0.0",
|
|
26
26
|
],
|
|
27
|
-
# Optional
|
|
27
|
+
# Optional dependencies
|
|
28
28
|
extras_require={
|
|
29
29
|
"dev": ["pytest", "black", "flake8"],
|
|
30
|
+
"yaml": ["PyYAML>=6.0"], # For itcpr.yml support
|
|
30
31
|
},
|
|
31
32
|
entry_points={
|
|
32
33
|
"console_scripts": [
|
|
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
|