itcpr 2.1.3__tar.gz → 2.1.4__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.1.3/itcpr.egg-info → itcpr-2.1.4}/PKG-INFO +107 -25
- {itcpr-2.1.3 → itcpr-2.1.4}/README.md +105 -22
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/__init__.py +1 -1
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/api.py +58 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/cli.py +139 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/gitops.py +103 -2
- {itcpr-2.1.3 → itcpr-2.1.4/itcpr.egg-info}/PKG-INFO +107 -25
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr.egg-info/requires.txt +1 -3
- {itcpr-2.1.3 → itcpr-2.1.4}/pyproject.toml +2 -2
- {itcpr-2.1.3 → itcpr-2.1.4}/setup.py +2 -2
- {itcpr-2.1.3 → itcpr-2.1.4}/LICENSE +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/MANIFEST.in +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/auth.py +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/config.py +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/storage.py +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/sync.py +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr/utils.py +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr.egg-info/SOURCES.txt +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr.egg-info/dependency_links.txt +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr.egg-info/entry_points.txt +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/itcpr.egg-info/top_level.txt +0 -0
- {itcpr-2.1.3 → itcpr-2.1.4}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itcpr
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: CLI tool for syncing GitHub repositories from ITCPR Cloud
|
|
5
5
|
Home-page: https://itcpr.org
|
|
6
6
|
Author: ITCPR
|
|
@@ -21,12 +21,11 @@ Requires-Dist: click>=8.0.0
|
|
|
21
21
|
Requires-Dist: requests>=2.28.0
|
|
22
22
|
Requires-Dist: keyring>=23.0.0
|
|
23
23
|
Requires-Dist: tomli-w>=1.0.0
|
|
24
|
+
Requires-Dist: PyYAML>=6.0
|
|
24
25
|
Provides-Extra: dev
|
|
25
26
|
Requires-Dist: pytest; extra == "dev"
|
|
26
27
|
Requires-Dist: black; extra == "dev"
|
|
27
28
|
Requires-Dist: flake8; extra == "dev"
|
|
28
|
-
Provides-Extra: yaml
|
|
29
|
-
Requires-Dist: PyYAML>=6.0; extra == "yaml"
|
|
30
29
|
Dynamic: author
|
|
31
30
|
Dynamic: home-page
|
|
32
31
|
Dynamic: license-file
|
|
@@ -39,6 +38,7 @@ A command-line tool for syncing GitHub repositories from ITCPR Cloud to your loc
|
|
|
39
38
|
## Features
|
|
40
39
|
|
|
41
40
|
- 🔐 Device-based authentication with ITCPR Cloud
|
|
41
|
+
- 🆕 Create new repositories in the organization
|
|
42
42
|
- 📦 Automatic repository synchronization
|
|
43
43
|
- 🔄 Manual or continuous sync modes
|
|
44
44
|
- 💾 Local SQLite database for metadata tracking
|
|
@@ -159,7 +159,40 @@ Or specify a custom path:
|
|
|
159
159
|
itcpr clone paperport-itcpr --path ~/projects/paperport
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
### 5.
|
|
162
|
+
### 5. Initialize a New Repository
|
|
163
|
+
|
|
164
|
+
Create a new repository in the current folder:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
itcpr init
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This will:
|
|
171
|
+
- Create a new repository in the organization (using current directory name)
|
|
172
|
+
- Add you as an admin collaborator
|
|
173
|
+
- Initialize git repository
|
|
174
|
+
- Set up remote origin
|
|
175
|
+
- Create an initial commit
|
|
176
|
+
|
|
177
|
+
With options:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Custom repository name (creates private repo by default)
|
|
181
|
+
itcpr init --name my-new-repo
|
|
182
|
+
|
|
183
|
+
# With description
|
|
184
|
+
itcpr init --name my-repo --description "My awesome project"
|
|
185
|
+
|
|
186
|
+
# Create public repository (default is private)
|
|
187
|
+
itcpr init --public
|
|
188
|
+
|
|
189
|
+
# Initialize and push immediately
|
|
190
|
+
itcpr init --push
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Note:** If the repository name already exists in the organization, you'll be prompted to choose a different name.
|
|
194
|
+
|
|
195
|
+
### 6. Sync Repositories
|
|
163
196
|
|
|
164
197
|
Sync all cloned repositories:
|
|
165
198
|
|
|
@@ -179,7 +212,17 @@ With custom interval:
|
|
|
179
212
|
itcpr sync --watch --interval 120 # Sync every 2 minutes
|
|
180
213
|
```
|
|
181
214
|
|
|
182
|
-
|
|
215
|
+
**Note:** Watch mode runs in the foreground and will block your terminal. Press `Ctrl+C` to stop. To run it in the background, you can use:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Run in background (Linux/macOS)
|
|
219
|
+
itcpr sync --watch &
|
|
220
|
+
|
|
221
|
+
# Or use nohup to keep it running after closing terminal
|
|
222
|
+
nohup itcpr sync --watch > itcpr.log 2>&1 &
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 7. Logout
|
|
183
226
|
|
|
184
227
|
Clear stored credentials:
|
|
185
228
|
|
|
@@ -218,6 +261,42 @@ Clones a repository from GitHub using short-lived installation tokens.
|
|
|
218
261
|
Options:
|
|
219
262
|
- `--path, -p`: Custom local path for the repository
|
|
220
263
|
|
|
264
|
+
### `itcpr init`
|
|
265
|
+
|
|
266
|
+
Creates a new repository in the organization and initializes it in the current folder. The repository name defaults to the current directory name, or you can specify a custom name.
|
|
267
|
+
|
|
268
|
+
**Options:**
|
|
269
|
+
- `--name, -n`: Repository name (defaults to current directory name)
|
|
270
|
+
- `--description, -d`: Repository description
|
|
271
|
+
- `--public`: Create a public repository (default: private)
|
|
272
|
+
- `--push`: Push initial commit to remote immediately
|
|
273
|
+
|
|
274
|
+
**What it does:**
|
|
275
|
+
1. Creates a new repository in the organization via GitHub API
|
|
276
|
+
2. Adds you (the device owner) as an admin collaborator
|
|
277
|
+
3. Initializes git repository if not already initialized
|
|
278
|
+
4. Sets up remote origin with authentication
|
|
279
|
+
5. Creates an initial commit (creates README.md if no files exist)
|
|
280
|
+
6. Optionally pushes to remote if `--push` is used
|
|
281
|
+
|
|
282
|
+
**Example:**
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Create repo with current directory name (private by default)
|
|
286
|
+
cd my-project
|
|
287
|
+
itcpr init
|
|
288
|
+
|
|
289
|
+
# Create repo with custom name
|
|
290
|
+
itcpr init --name awesome-project --description "My awesome project"
|
|
291
|
+
|
|
292
|
+
# Create public repo and push immediately
|
|
293
|
+
itcpr init --public --push
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Error handling:**
|
|
297
|
+
- If the repository name already exists, you'll see: "Repository 'name' already exists in the organization. Please choose a different name."
|
|
298
|
+
- If your GitHub account is not connected, you'll be prompted to connect it first.
|
|
299
|
+
|
|
221
300
|
### `itcpr sync`
|
|
222
301
|
|
|
223
302
|
Synchronizes all cloned repositories. By default, performs a one-time sync.
|
|
@@ -233,21 +312,20 @@ You can configure per-repository sync behavior by creating an `itcpr.yml` file i
|
|
|
233
312
|
```yaml
|
|
234
313
|
sync:
|
|
235
314
|
enabled: true # Enable/disable sync for this repo (default: true)
|
|
236
|
-
auto_commit: true # Auto-commit local changes (default: true)
|
|
237
|
-
auto_push: true # Auto-push local commits (default: true)
|
|
315
|
+
auto_commit: true # Auto-commit uncommitted local changes (default: true)
|
|
316
|
+
auto_push: true # Auto-push local commits to remote (default: true)
|
|
238
317
|
branch: main # Optional: specific branch to sync
|
|
239
318
|
ignore: # Optional: patterns to ignore
|
|
240
319
|
- "*.log"
|
|
241
320
|
- "temp/"
|
|
242
321
|
```
|
|
243
322
|
|
|
244
|
-
**Note:**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
```
|
|
323
|
+
**Note:** `auto_commit` and `auto_push` are independent settings:
|
|
324
|
+
- `auto_commit`: Automatically commits uncommitted changes in your working directory
|
|
325
|
+
- `auto_push`: Automatically pushes local commits to the remote repository
|
|
326
|
+
- If both are enabled (default), the tool will commit uncommitted changes and then push them automatically
|
|
327
|
+
- You can set `auto_commit: true, auto_push: false` to commit locally without pushing
|
|
328
|
+
- If `itcpr.yml` doesn't exist, the tool uses default values (all enabled). The configuration file is optional.
|
|
251
329
|
|
|
252
330
|
## How It Works
|
|
253
331
|
|
|
@@ -355,6 +433,21 @@ The repository must be assigned to your device in ITCPR Cloud. Make sure you've:
|
|
|
355
433
|
|
|
356
434
|
If the issue persists, contact an administrator.
|
|
357
435
|
|
|
436
|
+
### "Repository already exists" error (init command)
|
|
437
|
+
|
|
438
|
+
When running `itcpr init`, if you see this error, it means a repository with that name already exists in the organization. Choose a different name:
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
itcpr init --name different-name
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### "GitHub account not connected" error (init command)
|
|
445
|
+
|
|
446
|
+
The `init` command requires your GitHub account to be connected. Make sure you've:
|
|
447
|
+
1. Visited [cloud.itcpr.org](https://cloud.itcpr.org)
|
|
448
|
+
2. Connected your GitHub account
|
|
449
|
+
3. Then run `itcpr init` again
|
|
450
|
+
|
|
358
451
|
### Merge Conflicts
|
|
359
452
|
|
|
360
453
|
If a merge conflict is detected during sync:
|
|
@@ -421,17 +514,6 @@ itcpr --help
|
|
|
421
514
|
|
|
422
515
|
Contributions are welcome! Please ensure your code follows the project's style guidelines and includes appropriate tests.
|
|
423
516
|
|
|
424
|
-
## API Endpoints
|
|
425
|
-
|
|
426
|
-
The CLI communicates with these backend endpoints:
|
|
427
|
-
|
|
428
|
-
- `POST /api/device/start` - Start device authentication
|
|
429
|
-
- `GET /api/device/poll` - Poll for authentication approval
|
|
430
|
-
- `POST /api/device/revoke` - Revoke device token
|
|
431
|
-
- `GET /api/agent/me` - Get device/user information
|
|
432
|
-
- `GET /api/agent/repos` - Get assigned repositories
|
|
433
|
-
- `POST /api/agent/token` - Get GitHub installation token
|
|
434
|
-
|
|
435
517
|
## License
|
|
436
518
|
|
|
437
519
|
MIT License - see LICENSE file for details.
|
|
@@ -5,6 +5,7 @@ A command-line tool for syncing GitHub repositories from ITCPR Cloud to your loc
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
7
|
- 🔐 Device-based authentication with ITCPR Cloud
|
|
8
|
+
- 🆕 Create new repositories in the organization
|
|
8
9
|
- 📦 Automatic repository synchronization
|
|
9
10
|
- 🔄 Manual or continuous sync modes
|
|
10
11
|
- 💾 Local SQLite database for metadata tracking
|
|
@@ -125,7 +126,40 @@ Or specify a custom path:
|
|
|
125
126
|
itcpr clone paperport-itcpr --path ~/projects/paperport
|
|
126
127
|
```
|
|
127
128
|
|
|
128
|
-
### 5.
|
|
129
|
+
### 5. Initialize a New Repository
|
|
130
|
+
|
|
131
|
+
Create a new repository in the current folder:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
itcpr init
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
This will:
|
|
138
|
+
- Create a new repository in the organization (using current directory name)
|
|
139
|
+
- Add you as an admin collaborator
|
|
140
|
+
- Initialize git repository
|
|
141
|
+
- Set up remote origin
|
|
142
|
+
- Create an initial commit
|
|
143
|
+
|
|
144
|
+
With options:
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Custom repository name (creates private repo by default)
|
|
148
|
+
itcpr init --name my-new-repo
|
|
149
|
+
|
|
150
|
+
# With description
|
|
151
|
+
itcpr init --name my-repo --description "My awesome project"
|
|
152
|
+
|
|
153
|
+
# Create public repository (default is private)
|
|
154
|
+
itcpr init --public
|
|
155
|
+
|
|
156
|
+
# Initialize and push immediately
|
|
157
|
+
itcpr init --push
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Note:** If the repository name already exists in the organization, you'll be prompted to choose a different name.
|
|
161
|
+
|
|
162
|
+
### 6. Sync Repositories
|
|
129
163
|
|
|
130
164
|
Sync all cloned repositories:
|
|
131
165
|
|
|
@@ -145,7 +179,17 @@ With custom interval:
|
|
|
145
179
|
itcpr sync --watch --interval 120 # Sync every 2 minutes
|
|
146
180
|
```
|
|
147
181
|
|
|
148
|
-
|
|
182
|
+
**Note:** Watch mode runs in the foreground and will block your terminal. Press `Ctrl+C` to stop. To run it in the background, you can use:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Run in background (Linux/macOS)
|
|
186
|
+
itcpr sync --watch &
|
|
187
|
+
|
|
188
|
+
# Or use nohup to keep it running after closing terminal
|
|
189
|
+
nohup itcpr sync --watch > itcpr.log 2>&1 &
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### 7. Logout
|
|
149
193
|
|
|
150
194
|
Clear stored credentials:
|
|
151
195
|
|
|
@@ -184,6 +228,42 @@ Clones a repository from GitHub using short-lived installation tokens.
|
|
|
184
228
|
Options:
|
|
185
229
|
- `--path, -p`: Custom local path for the repository
|
|
186
230
|
|
|
231
|
+
### `itcpr init`
|
|
232
|
+
|
|
233
|
+
Creates a new repository in the organization and initializes it in the current folder. The repository name defaults to the current directory name, or you can specify a custom name.
|
|
234
|
+
|
|
235
|
+
**Options:**
|
|
236
|
+
- `--name, -n`: Repository name (defaults to current directory name)
|
|
237
|
+
- `--description, -d`: Repository description
|
|
238
|
+
- `--public`: Create a public repository (default: private)
|
|
239
|
+
- `--push`: Push initial commit to remote immediately
|
|
240
|
+
|
|
241
|
+
**What it does:**
|
|
242
|
+
1. Creates a new repository in the organization via GitHub API
|
|
243
|
+
2. Adds you (the device owner) as an admin collaborator
|
|
244
|
+
3. Initializes git repository if not already initialized
|
|
245
|
+
4. Sets up remote origin with authentication
|
|
246
|
+
5. Creates an initial commit (creates README.md if no files exist)
|
|
247
|
+
6. Optionally pushes to remote if `--push` is used
|
|
248
|
+
|
|
249
|
+
**Example:**
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Create repo with current directory name (private by default)
|
|
253
|
+
cd my-project
|
|
254
|
+
itcpr init
|
|
255
|
+
|
|
256
|
+
# Create repo with custom name
|
|
257
|
+
itcpr init --name awesome-project --description "My awesome project"
|
|
258
|
+
|
|
259
|
+
# Create public repo and push immediately
|
|
260
|
+
itcpr init --public --push
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
**Error handling:**
|
|
264
|
+
- If the repository name already exists, you'll see: "Repository 'name' already exists in the organization. Please choose a different name."
|
|
265
|
+
- If your GitHub account is not connected, you'll be prompted to connect it first.
|
|
266
|
+
|
|
187
267
|
### `itcpr sync`
|
|
188
268
|
|
|
189
269
|
Synchronizes all cloned repositories. By default, performs a one-time sync.
|
|
@@ -199,21 +279,20 @@ You can configure per-repository sync behavior by creating an `itcpr.yml` file i
|
|
|
199
279
|
```yaml
|
|
200
280
|
sync:
|
|
201
281
|
enabled: true # Enable/disable sync for this repo (default: true)
|
|
202
|
-
auto_commit: true # Auto-commit local changes (default: true)
|
|
203
|
-
auto_push: true # Auto-push local commits (default: true)
|
|
282
|
+
auto_commit: true # Auto-commit uncommitted local changes (default: true)
|
|
283
|
+
auto_push: true # Auto-push local commits to remote (default: true)
|
|
204
284
|
branch: main # Optional: specific branch to sync
|
|
205
285
|
ignore: # Optional: patterns to ignore
|
|
206
286
|
- "*.log"
|
|
207
287
|
- "temp/"
|
|
208
288
|
```
|
|
209
289
|
|
|
210
|
-
**Note:**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
```
|
|
290
|
+
**Note:** `auto_commit` and `auto_push` are independent settings:
|
|
291
|
+
- `auto_commit`: Automatically commits uncommitted changes in your working directory
|
|
292
|
+
- `auto_push`: Automatically pushes local commits to the remote repository
|
|
293
|
+
- If both are enabled (default), the tool will commit uncommitted changes and then push them automatically
|
|
294
|
+
- You can set `auto_commit: true, auto_push: false` to commit locally without pushing
|
|
295
|
+
- If `itcpr.yml` doesn't exist, the tool uses default values (all enabled). The configuration file is optional.
|
|
217
296
|
|
|
218
297
|
## How It Works
|
|
219
298
|
|
|
@@ -321,6 +400,21 @@ The repository must be assigned to your device in ITCPR Cloud. Make sure you've:
|
|
|
321
400
|
|
|
322
401
|
If the issue persists, contact an administrator.
|
|
323
402
|
|
|
403
|
+
### "Repository already exists" error (init command)
|
|
404
|
+
|
|
405
|
+
When running `itcpr init`, if you see this error, it means a repository with that name already exists in the organization. Choose a different name:
|
|
406
|
+
|
|
407
|
+
```bash
|
|
408
|
+
itcpr init --name different-name
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### "GitHub account not connected" error (init command)
|
|
412
|
+
|
|
413
|
+
The `init` command requires your GitHub account to be connected. Make sure you've:
|
|
414
|
+
1. Visited [cloud.itcpr.org](https://cloud.itcpr.org)
|
|
415
|
+
2. Connected your GitHub account
|
|
416
|
+
3. Then run `itcpr init` again
|
|
417
|
+
|
|
324
418
|
### Merge Conflicts
|
|
325
419
|
|
|
326
420
|
If a merge conflict is detected during sync:
|
|
@@ -387,17 +481,6 @@ itcpr --help
|
|
|
387
481
|
|
|
388
482
|
Contributions are welcome! Please ensure your code follows the project's style guidelines and includes appropriate tests.
|
|
389
483
|
|
|
390
|
-
## API Endpoints
|
|
391
|
-
|
|
392
|
-
The CLI communicates with these backend endpoints:
|
|
393
|
-
|
|
394
|
-
- `POST /api/device/start` - Start device authentication
|
|
395
|
-
- `GET /api/device/poll` - Poll for authentication approval
|
|
396
|
-
- `POST /api/device/revoke` - Revoke device token
|
|
397
|
-
- `GET /api/agent/me` - Get device/user information
|
|
398
|
-
- `GET /api/agent/repos` - Get assigned repositories
|
|
399
|
-
- `POST /api/agent/token` - Get GitHub installation token
|
|
400
|
-
|
|
401
484
|
## License
|
|
402
485
|
|
|
403
486
|
MIT License - see LICENSE file for details.
|
|
@@ -112,4 +112,62 @@ class APIClient:
|
|
|
112
112
|
raise
|
|
113
113
|
except Exception:
|
|
114
114
|
return False
|
|
115
|
+
|
|
116
|
+
def create_repo(self, name: str, description: str = "", private: bool = False) -> Dict[str, Any]:
|
|
117
|
+
"""Create a new repository in the organization."""
|
|
118
|
+
use_mock = config.mock_mode or (MOCK_AVAILABLE and _mock_api is not None)
|
|
119
|
+
|
|
120
|
+
payload = {
|
|
121
|
+
"name": name,
|
|
122
|
+
"description": description,
|
|
123
|
+
"visibility": "private" if private else "public"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
try:
|
|
127
|
+
response = self._request("POST", "/cloud/app/org/repos", json=payload)
|
|
128
|
+
response.raise_for_status()
|
|
129
|
+
return response.json()
|
|
130
|
+
except requests.HTTPError as e:
|
|
131
|
+
if e.response.status_code == 422:
|
|
132
|
+
# GitHub API returns 422 when repo already exists
|
|
133
|
+
error_data = e.response.json()
|
|
134
|
+
error_message = error_data.get("message", "Repository already exists")
|
|
135
|
+
if "already exists" in error_message.lower() or "name already exists" in error_message.lower():
|
|
136
|
+
raise ValueError(f"Repository '{name}' already exists in the organization. Please choose a different name.")
|
|
137
|
+
raise ValueError(error_message)
|
|
138
|
+
if use_mock and e.response.status_code == 404:
|
|
139
|
+
logger.info("Backend unavailable, using mock API")
|
|
140
|
+
if MOCK_AVAILABLE:
|
|
141
|
+
return _mock_api.create_repo(name, description, private)
|
|
142
|
+
raise
|
|
143
|
+
except (requests.RequestException, Exception) as e:
|
|
144
|
+
if use_mock:
|
|
145
|
+
logger.info("Backend unavailable, using mock API")
|
|
146
|
+
if MOCK_AVAILABLE:
|
|
147
|
+
return _mock_api.create_repo(name, description, private)
|
|
148
|
+
raise
|
|
149
|
+
|
|
150
|
+
def add_collaborator(self, owner: str, repo: str, username: str, permission: str = "admin") -> bool:
|
|
151
|
+
"""Add a collaborator to a repository."""
|
|
152
|
+
use_mock = config.mock_mode or (MOCK_AVAILABLE and _mock_api is not None)
|
|
153
|
+
|
|
154
|
+
payload = {"permission": permission}
|
|
155
|
+
|
|
156
|
+
try:
|
|
157
|
+
response = self._request("PUT", f"/cloud/app/repos/{owner}/{repo}/collaborators/{username}", json=payload)
|
|
158
|
+
response.raise_for_status()
|
|
159
|
+
return True
|
|
160
|
+
except requests.HTTPError as e:
|
|
161
|
+
if use_mock and e.response.status_code == 404:
|
|
162
|
+
logger.info("Backend unavailable, using mock API")
|
|
163
|
+
# Mock would silently succeed
|
|
164
|
+
return True
|
|
165
|
+
logger.warning(f"Failed to add collaborator: {e}")
|
|
166
|
+
raise
|
|
167
|
+
except (requests.RequestException, Exception) as e:
|
|
168
|
+
if use_mock:
|
|
169
|
+
logger.info("Backend unavailable, using mock API")
|
|
170
|
+
return True
|
|
171
|
+
logger.warning(f"Failed to add collaborator: {e}")
|
|
172
|
+
raise
|
|
115
173
|
|
|
@@ -263,6 +263,145 @@ def sync(ctx, watch, interval):
|
|
|
263
263
|
print_error(f"Sync failed: {e}")
|
|
264
264
|
raise click.Abort()
|
|
265
265
|
|
|
266
|
+
@cli.command()
|
|
267
|
+
@click.option("--name", "-n", help="Repository name (defaults to current directory name)")
|
|
268
|
+
@click.option("--description", "-d", default="", help="Repository description")
|
|
269
|
+
@click.option("--public", is_flag=True, help="Create public repository (default: private)")
|
|
270
|
+
@click.option("--push", is_flag=True, help="Push initial commit to remote")
|
|
271
|
+
@click.pass_context
|
|
272
|
+
def init(ctx, name, description, public, push):
|
|
273
|
+
"""Initialize a new repository in the current folder."""
|
|
274
|
+
from .auth import Auth
|
|
275
|
+
from .api import APIClient
|
|
276
|
+
from .storage import Storage
|
|
277
|
+
from .gitops import GitOps
|
|
278
|
+
auth = Auth()
|
|
279
|
+
if not auth.is_authenticated():
|
|
280
|
+
click.echo("Not logged in. Run 'itcpr login' first.")
|
|
281
|
+
return
|
|
282
|
+
|
|
283
|
+
api = APIClient(auth)
|
|
284
|
+
storage = Storage()
|
|
285
|
+
|
|
286
|
+
try:
|
|
287
|
+
# Get current directory
|
|
288
|
+
current_dir = Path.cwd()
|
|
289
|
+
|
|
290
|
+
# Determine repository name
|
|
291
|
+
if name:
|
|
292
|
+
repo_name = name
|
|
293
|
+
else:
|
|
294
|
+
repo_name = current_dir.name
|
|
295
|
+
if not repo_name or repo_name == ".":
|
|
296
|
+
print_error("Cannot determine repository name. Please specify --name")
|
|
297
|
+
raise click.Abort()
|
|
298
|
+
|
|
299
|
+
# Check if already a git repo
|
|
300
|
+
git = GitOps(current_dir)
|
|
301
|
+
is_git_repo = git.is_repo()
|
|
302
|
+
|
|
303
|
+
if is_git_repo:
|
|
304
|
+
click.echo(f"Directory is already a git repository.")
|
|
305
|
+
if not click.confirm("Continue with creating remote repository?"):
|
|
306
|
+
return
|
|
307
|
+
|
|
308
|
+
# Get user's GitHub username
|
|
309
|
+
click.echo("Getting user information...")
|
|
310
|
+
try:
|
|
311
|
+
me = api.get_me()
|
|
312
|
+
user_data = me.get("user", {})
|
|
313
|
+
github_username = user_data.get("github_username")
|
|
314
|
+
if not github_username:
|
|
315
|
+
print_error("GitHub account not connected. Please connect your GitHub account first.")
|
|
316
|
+
raise click.Abort()
|
|
317
|
+
except Exception as e:
|
|
318
|
+
logger.warning(f"Could not get user info: {e}")
|
|
319
|
+
github_username = None
|
|
320
|
+
|
|
321
|
+
# Create repository on GitHub (private by default, unless --public is specified)
|
|
322
|
+
private = not public
|
|
323
|
+
click.echo(f"Creating repository '{repo_name}' in organization ({'private' if private else 'public'})...")
|
|
324
|
+
try:
|
|
325
|
+
repo_data = api.create_repo(repo_name, description, private)
|
|
326
|
+
print_success(f"Repository '{repo_name}' created successfully")
|
|
327
|
+
except ValueError as e:
|
|
328
|
+
# Handle "already exists" error
|
|
329
|
+
error_msg = str(e)
|
|
330
|
+
if "already exists" in error_msg.lower():
|
|
331
|
+
print_error(f"Repository '{repo_name}' already exists in the organization. Please choose a different name.")
|
|
332
|
+
raise click.Abort()
|
|
333
|
+
raise
|
|
334
|
+
|
|
335
|
+
# Get repository owner and URLs
|
|
336
|
+
full_name = repo_data.get("full_name", "")
|
|
337
|
+
owner = full_name.split("/")[0] if "/" in full_name else repo_data.get("owner", {}).get("login", "")
|
|
338
|
+
clone_url = repo_data.get("clone_url")
|
|
339
|
+
ssh_url = repo_data.get("ssh_url")
|
|
340
|
+
remote_url = clone_url or ssh_url
|
|
341
|
+
|
|
342
|
+
if not remote_url:
|
|
343
|
+
print_error("Repository created but URL not available")
|
|
344
|
+
raise click.Abort()
|
|
345
|
+
|
|
346
|
+
# Add device owner as admin collaborator
|
|
347
|
+
if github_username and owner:
|
|
348
|
+
click.echo(f"Adding you as admin collaborator...")
|
|
349
|
+
try:
|
|
350
|
+
api.add_collaborator(owner, repo_name, github_username, permission="admin")
|
|
351
|
+
print_success(f"Added {github_username} as admin collaborator")
|
|
352
|
+
except Exception as e:
|
|
353
|
+
logger.warning(f"Failed to add collaborator: {e}")
|
|
354
|
+
click.echo(f"Warning: Could not add you as collaborator. You may need to add yourself manually.")
|
|
355
|
+
|
|
356
|
+
# Initialize git if not already initialized
|
|
357
|
+
if not is_git_repo:
|
|
358
|
+
click.echo("Initializing git repository...")
|
|
359
|
+
git.init()
|
|
360
|
+
print_success("Git repository initialized")
|
|
361
|
+
|
|
362
|
+
# Get GitHub token for remote operations
|
|
363
|
+
click.echo("Setting up remote...")
|
|
364
|
+
token = api.get_github_token(repo_name)
|
|
365
|
+
|
|
366
|
+
# Add remote
|
|
367
|
+
git.add_remote("origin", remote_url, token)
|
|
368
|
+
print_success("Remote 'origin' configured")
|
|
369
|
+
|
|
370
|
+
# Create initial commit if there are changes or no commits
|
|
371
|
+
try:
|
|
372
|
+
git.create_initial_commit("Initial commit")
|
|
373
|
+
click.echo("Initial commit created")
|
|
374
|
+
except Exception as e:
|
|
375
|
+
logger.debug(f"Could not create initial commit: {e}")
|
|
376
|
+
# This is okay, might already have commits or no files
|
|
377
|
+
|
|
378
|
+
# Push if requested
|
|
379
|
+
if push:
|
|
380
|
+
click.echo("Pushing to remote...")
|
|
381
|
+
try:
|
|
382
|
+
branch = git.get_current_branch() or "main"
|
|
383
|
+
git.push(set_upstream=True)
|
|
384
|
+
print_success(f"Pushed to remote (branch: {branch})")
|
|
385
|
+
except Exception as e:
|
|
386
|
+
logger.warning(f"Push failed: {e}")
|
|
387
|
+
print_error(f"Failed to push: {e}")
|
|
388
|
+
click.echo("You can push manually later with: git push -u origin <branch>")
|
|
389
|
+
|
|
390
|
+
# Register in storage
|
|
391
|
+
full_name = repo_data.get("full_name", repo_name)
|
|
392
|
+
storage.add_repo(repo_name, full_name, str(current_dir), remote_url)
|
|
393
|
+
|
|
394
|
+
print_success(f"Repository '{repo_name}' initialized successfully!")
|
|
395
|
+
if not push:
|
|
396
|
+
click.echo(f"\nTo push your code, run: git push -u origin {git.get_current_branch() or 'main'}")
|
|
397
|
+
|
|
398
|
+
except click.Abort:
|
|
399
|
+
raise
|
|
400
|
+
except Exception as e:
|
|
401
|
+
logger.exception("Init error")
|
|
402
|
+
print_error(f"Failed to initialize repository: {e}")
|
|
403
|
+
raise click.Abort()
|
|
404
|
+
|
|
266
405
|
def main():
|
|
267
406
|
"""Entry point for CLI."""
|
|
268
407
|
cli()
|
|
@@ -191,13 +191,17 @@ class GitOps:
|
|
|
191
191
|
logger.error(f"Commit failed: {e}")
|
|
192
192
|
raise
|
|
193
193
|
|
|
194
|
-
def push(self) -> bool:
|
|
194
|
+
def push(self, set_upstream: bool = False) -> bool:
|
|
195
195
|
"""Push to remote."""
|
|
196
196
|
if not self.is_repo():
|
|
197
197
|
raise RuntimeError("Not a git repository")
|
|
198
198
|
|
|
199
199
|
try:
|
|
200
|
-
self.
|
|
200
|
+
branch = self.get_current_branch() or "main"
|
|
201
|
+
if set_upstream:
|
|
202
|
+
self._run_git("push", "-u", "origin", branch, check=True)
|
|
203
|
+
else:
|
|
204
|
+
self._run_git("push", "origin", "HEAD", check=True)
|
|
201
205
|
return True
|
|
202
206
|
except Exception as e:
|
|
203
207
|
logger.error(f"Push failed: {e}")
|
|
@@ -224,4 +228,101 @@ class GitOps:
|
|
|
224
228
|
return result.stdout.strip()
|
|
225
229
|
except:
|
|
226
230
|
return None
|
|
231
|
+
|
|
232
|
+
def init(self) -> bool:
|
|
233
|
+
"""Initialize a new git repository."""
|
|
234
|
+
if self.is_repo():
|
|
235
|
+
raise RuntimeError("Already a git repository")
|
|
236
|
+
|
|
237
|
+
try:
|
|
238
|
+
# Ensure directory exists
|
|
239
|
+
self.repo_path.mkdir(parents=True, exist_ok=True)
|
|
240
|
+
# Initialize git repo
|
|
241
|
+
self._run_git("init", check=True, cwd=self.repo_path)
|
|
242
|
+
return True
|
|
243
|
+
except Exception as e:
|
|
244
|
+
logger.error(f"Git init failed: {e}")
|
|
245
|
+
raise
|
|
246
|
+
|
|
247
|
+
def add_remote(self, name: str, url: str, token: Optional[str] = None) -> bool:
|
|
248
|
+
"""Add remote repository."""
|
|
249
|
+
if not self.is_repo():
|
|
250
|
+
raise RuntimeError("Not a git repository")
|
|
251
|
+
|
|
252
|
+
# Prepare URL with token if provided
|
|
253
|
+
if token:
|
|
254
|
+
if url.startswith("https://"):
|
|
255
|
+
url_parts = url.split("://", 1)
|
|
256
|
+
url = f"{url_parts[0]}://x-access-token:{token}@{url_parts[1]}"
|
|
257
|
+
elif url.startswith("git@"):
|
|
258
|
+
ssh_parts = url.replace("git@", "").replace(":", "/", 1)
|
|
259
|
+
url = f"https://x-access-token:{token}@{ssh_parts}"
|
|
260
|
+
|
|
261
|
+
try:
|
|
262
|
+
# Check if remote already exists
|
|
263
|
+
try:
|
|
264
|
+
existing_url = self._run_git("remote", "get-url", name, check=True)
|
|
265
|
+
if existing_url.stdout.strip() != url:
|
|
266
|
+
# Update existing remote
|
|
267
|
+
self._run_git("remote", "set-url", name, url, check=True)
|
|
268
|
+
except:
|
|
269
|
+
# Remote doesn't exist, add it
|
|
270
|
+
self._run_git("remote", "add", name, url, check=True)
|
|
271
|
+
return True
|
|
272
|
+
except Exception as e:
|
|
273
|
+
logger.error(f"Add remote failed: {e}")
|
|
274
|
+
raise
|
|
275
|
+
|
|
276
|
+
def create_initial_commit(self, message: str = "Initial commit") -> bool:
|
|
277
|
+
"""Create initial commit if there are files to commit."""
|
|
278
|
+
if not self.is_repo():
|
|
279
|
+
raise RuntimeError("Not a git repository")
|
|
280
|
+
|
|
281
|
+
try:
|
|
282
|
+
# First check if there are any commits
|
|
283
|
+
has_commits = False
|
|
284
|
+
try:
|
|
285
|
+
self._run_git("rev-parse", "--verify", "HEAD", check=True)
|
|
286
|
+
has_commits = True
|
|
287
|
+
except:
|
|
288
|
+
# No commits yet
|
|
289
|
+
has_commits = False
|
|
290
|
+
|
|
291
|
+
# If already has commits, check status normally
|
|
292
|
+
if has_commits:
|
|
293
|
+
status = self.get_status()
|
|
294
|
+
if not status.get("has_changes"):
|
|
295
|
+
# Already has commits and no changes
|
|
296
|
+
return False
|
|
297
|
+
# Has commits and changes, add and commit
|
|
298
|
+
self._run_git("add", "-A", check=True)
|
|
299
|
+
self._run_git("commit", "-m", message, check=True)
|
|
300
|
+
return True
|
|
301
|
+
|
|
302
|
+
# No commits yet - check if there are any files to commit
|
|
303
|
+
# Use git status --porcelain to check for changes without needing HEAD
|
|
304
|
+
try:
|
|
305
|
+
status_result = self._run_git("status", "--porcelain", check=True)
|
|
306
|
+
has_changes = bool(status_result.stdout.strip())
|
|
307
|
+
except:
|
|
308
|
+
has_changes = False
|
|
309
|
+
|
|
310
|
+
# If no changes, create a README
|
|
311
|
+
if not has_changes:
|
|
312
|
+
readme_path = self.repo_path / "README.md"
|
|
313
|
+
if not readme_path.exists():
|
|
314
|
+
readme_path.write_text(f"# {self.repo_path.name}\n\n")
|
|
315
|
+
has_changes = True
|
|
316
|
+
|
|
317
|
+
if has_changes:
|
|
318
|
+
# Add all files
|
|
319
|
+
self._run_git("add", "-A", check=True)
|
|
320
|
+
# Commit
|
|
321
|
+
self._run_git("commit", "-m", message, check=True)
|
|
322
|
+
return True
|
|
323
|
+
|
|
324
|
+
return False
|
|
325
|
+
except Exception as e:
|
|
326
|
+
logger.error(f"Create initial commit failed: {e}")
|
|
327
|
+
raise
|
|
227
328
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: itcpr
|
|
3
|
-
Version: 2.1.
|
|
3
|
+
Version: 2.1.4
|
|
4
4
|
Summary: CLI tool for syncing GitHub repositories from ITCPR Cloud
|
|
5
5
|
Home-page: https://itcpr.org
|
|
6
6
|
Author: ITCPR
|
|
@@ -21,12 +21,11 @@ Requires-Dist: click>=8.0.0
|
|
|
21
21
|
Requires-Dist: requests>=2.28.0
|
|
22
22
|
Requires-Dist: keyring>=23.0.0
|
|
23
23
|
Requires-Dist: tomli-w>=1.0.0
|
|
24
|
+
Requires-Dist: PyYAML>=6.0
|
|
24
25
|
Provides-Extra: dev
|
|
25
26
|
Requires-Dist: pytest; extra == "dev"
|
|
26
27
|
Requires-Dist: black; extra == "dev"
|
|
27
28
|
Requires-Dist: flake8; extra == "dev"
|
|
28
|
-
Provides-Extra: yaml
|
|
29
|
-
Requires-Dist: PyYAML>=6.0; extra == "yaml"
|
|
30
29
|
Dynamic: author
|
|
31
30
|
Dynamic: home-page
|
|
32
31
|
Dynamic: license-file
|
|
@@ -39,6 +38,7 @@ A command-line tool for syncing GitHub repositories from ITCPR Cloud to your loc
|
|
|
39
38
|
## Features
|
|
40
39
|
|
|
41
40
|
- 🔐 Device-based authentication with ITCPR Cloud
|
|
41
|
+
- 🆕 Create new repositories in the organization
|
|
42
42
|
- 📦 Automatic repository synchronization
|
|
43
43
|
- 🔄 Manual or continuous sync modes
|
|
44
44
|
- 💾 Local SQLite database for metadata tracking
|
|
@@ -159,7 +159,40 @@ Or specify a custom path:
|
|
|
159
159
|
itcpr clone paperport-itcpr --path ~/projects/paperport
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
### 5.
|
|
162
|
+
### 5. Initialize a New Repository
|
|
163
|
+
|
|
164
|
+
Create a new repository in the current folder:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
itcpr init
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This will:
|
|
171
|
+
- Create a new repository in the organization (using current directory name)
|
|
172
|
+
- Add you as an admin collaborator
|
|
173
|
+
- Initialize git repository
|
|
174
|
+
- Set up remote origin
|
|
175
|
+
- Create an initial commit
|
|
176
|
+
|
|
177
|
+
With options:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Custom repository name (creates private repo by default)
|
|
181
|
+
itcpr init --name my-new-repo
|
|
182
|
+
|
|
183
|
+
# With description
|
|
184
|
+
itcpr init --name my-repo --description "My awesome project"
|
|
185
|
+
|
|
186
|
+
# Create public repository (default is private)
|
|
187
|
+
itcpr init --public
|
|
188
|
+
|
|
189
|
+
# Initialize and push immediately
|
|
190
|
+
itcpr init --push
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Note:** If the repository name already exists in the organization, you'll be prompted to choose a different name.
|
|
194
|
+
|
|
195
|
+
### 6. Sync Repositories
|
|
163
196
|
|
|
164
197
|
Sync all cloned repositories:
|
|
165
198
|
|
|
@@ -179,7 +212,17 @@ With custom interval:
|
|
|
179
212
|
itcpr sync --watch --interval 120 # Sync every 2 minutes
|
|
180
213
|
```
|
|
181
214
|
|
|
182
|
-
|
|
215
|
+
**Note:** Watch mode runs in the foreground and will block your terminal. Press `Ctrl+C` to stop. To run it in the background, you can use:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
# Run in background (Linux/macOS)
|
|
219
|
+
itcpr sync --watch &
|
|
220
|
+
|
|
221
|
+
# Or use nohup to keep it running after closing terminal
|
|
222
|
+
nohup itcpr sync --watch > itcpr.log 2>&1 &
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 7. Logout
|
|
183
226
|
|
|
184
227
|
Clear stored credentials:
|
|
185
228
|
|
|
@@ -218,6 +261,42 @@ Clones a repository from GitHub using short-lived installation tokens.
|
|
|
218
261
|
Options:
|
|
219
262
|
- `--path, -p`: Custom local path for the repository
|
|
220
263
|
|
|
264
|
+
### `itcpr init`
|
|
265
|
+
|
|
266
|
+
Creates a new repository in the organization and initializes it in the current folder. The repository name defaults to the current directory name, or you can specify a custom name.
|
|
267
|
+
|
|
268
|
+
**Options:**
|
|
269
|
+
- `--name, -n`: Repository name (defaults to current directory name)
|
|
270
|
+
- `--description, -d`: Repository description
|
|
271
|
+
- `--public`: Create a public repository (default: private)
|
|
272
|
+
- `--push`: Push initial commit to remote immediately
|
|
273
|
+
|
|
274
|
+
**What it does:**
|
|
275
|
+
1. Creates a new repository in the organization via GitHub API
|
|
276
|
+
2. Adds you (the device owner) as an admin collaborator
|
|
277
|
+
3. Initializes git repository if not already initialized
|
|
278
|
+
4. Sets up remote origin with authentication
|
|
279
|
+
5. Creates an initial commit (creates README.md if no files exist)
|
|
280
|
+
6. Optionally pushes to remote if `--push` is used
|
|
281
|
+
|
|
282
|
+
**Example:**
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# Create repo with current directory name (private by default)
|
|
286
|
+
cd my-project
|
|
287
|
+
itcpr init
|
|
288
|
+
|
|
289
|
+
# Create repo with custom name
|
|
290
|
+
itcpr init --name awesome-project --description "My awesome project"
|
|
291
|
+
|
|
292
|
+
# Create public repo and push immediately
|
|
293
|
+
itcpr init --public --push
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Error handling:**
|
|
297
|
+
- If the repository name already exists, you'll see: "Repository 'name' already exists in the organization. Please choose a different name."
|
|
298
|
+
- If your GitHub account is not connected, you'll be prompted to connect it first.
|
|
299
|
+
|
|
221
300
|
### `itcpr sync`
|
|
222
301
|
|
|
223
302
|
Synchronizes all cloned repositories. By default, performs a one-time sync.
|
|
@@ -233,21 +312,20 @@ You can configure per-repository sync behavior by creating an `itcpr.yml` file i
|
|
|
233
312
|
```yaml
|
|
234
313
|
sync:
|
|
235
314
|
enabled: true # Enable/disable sync for this repo (default: true)
|
|
236
|
-
auto_commit: true # Auto-commit local changes (default: true)
|
|
237
|
-
auto_push: true # Auto-push local commits (default: true)
|
|
315
|
+
auto_commit: true # Auto-commit uncommitted local changes (default: true)
|
|
316
|
+
auto_push: true # Auto-push local commits to remote (default: true)
|
|
238
317
|
branch: main # Optional: specific branch to sync
|
|
239
318
|
ignore: # Optional: patterns to ignore
|
|
240
319
|
- "*.log"
|
|
241
320
|
- "temp/"
|
|
242
321
|
```
|
|
243
322
|
|
|
244
|
-
**Note:**
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
```
|
|
323
|
+
**Note:** `auto_commit` and `auto_push` are independent settings:
|
|
324
|
+
- `auto_commit`: Automatically commits uncommitted changes in your working directory
|
|
325
|
+
- `auto_push`: Automatically pushes local commits to the remote repository
|
|
326
|
+
- If both are enabled (default), the tool will commit uncommitted changes and then push them automatically
|
|
327
|
+
- You can set `auto_commit: true, auto_push: false` to commit locally without pushing
|
|
328
|
+
- If `itcpr.yml` doesn't exist, the tool uses default values (all enabled). The configuration file is optional.
|
|
251
329
|
|
|
252
330
|
## How It Works
|
|
253
331
|
|
|
@@ -355,6 +433,21 @@ The repository must be assigned to your device in ITCPR Cloud. Make sure you've:
|
|
|
355
433
|
|
|
356
434
|
If the issue persists, contact an administrator.
|
|
357
435
|
|
|
436
|
+
### "Repository already exists" error (init command)
|
|
437
|
+
|
|
438
|
+
When running `itcpr init`, if you see this error, it means a repository with that name already exists in the organization. Choose a different name:
|
|
439
|
+
|
|
440
|
+
```bash
|
|
441
|
+
itcpr init --name different-name
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
### "GitHub account not connected" error (init command)
|
|
445
|
+
|
|
446
|
+
The `init` command requires your GitHub account to be connected. Make sure you've:
|
|
447
|
+
1. Visited [cloud.itcpr.org](https://cloud.itcpr.org)
|
|
448
|
+
2. Connected your GitHub account
|
|
449
|
+
3. Then run `itcpr init` again
|
|
450
|
+
|
|
358
451
|
### Merge Conflicts
|
|
359
452
|
|
|
360
453
|
If a merge conflict is detected during sync:
|
|
@@ -421,17 +514,6 @@ itcpr --help
|
|
|
421
514
|
|
|
422
515
|
Contributions are welcome! Please ensure your code follows the project's style guidelines and includes appropriate tests.
|
|
423
516
|
|
|
424
|
-
## API Endpoints
|
|
425
|
-
|
|
426
|
-
The CLI communicates with these backend endpoints:
|
|
427
|
-
|
|
428
|
-
- `POST /api/device/start` - Start device authentication
|
|
429
|
-
- `GET /api/device/poll` - Poll for authentication approval
|
|
430
|
-
- `POST /api/device/revoke` - Revoke device token
|
|
431
|
-
- `GET /api/agent/me` - Get device/user information
|
|
432
|
-
- `GET /api/agent/repos` - Get assigned repositories
|
|
433
|
-
- `POST /api/agent/token` - Get GitHub installation token
|
|
434
|
-
|
|
435
517
|
## License
|
|
436
518
|
|
|
437
519
|
MIT License - see LICENSE file for details.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "itcpr"
|
|
7
|
-
version = "2.1.
|
|
7
|
+
version = "2.1.4"
|
|
8
8
|
description = "CLI tool for syncing GitHub repositories from ITCPR Cloud"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -27,6 +27,7 @@ dependencies = [
|
|
|
27
27
|
"requests>=2.28.0",
|
|
28
28
|
"keyring>=23.0.0",
|
|
29
29
|
"tomli-w>=1.0.0",
|
|
30
|
+
"PyYAML>=6.0",
|
|
30
31
|
]
|
|
31
32
|
|
|
32
33
|
[project.scripts]
|
|
@@ -34,7 +35,6 @@ itcpr = "itcpr.cli:main"
|
|
|
34
35
|
|
|
35
36
|
[project.optional-dependencies]
|
|
36
37
|
dev = ["pytest", "black", "flake8"]
|
|
37
|
-
yaml = ["PyYAML>=6.0"] # For itcpr.yml support
|
|
38
38
|
|
|
39
39
|
[tool.setuptools]
|
|
40
40
|
packages = ["itcpr"]
|
|
@@ -9,7 +9,7 @@ long_description = readme_file.read_text() if readme_file.exists() else ""
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name="itcpr",
|
|
12
|
-
version="2.1.
|
|
12
|
+
version="2.1.4",
|
|
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",
|
|
@@ -23,11 +23,11 @@ setup(
|
|
|
23
23
|
"requests>=2.28.0",
|
|
24
24
|
"keyring>=23.0.0",
|
|
25
25
|
"tomli-w>=1.0.0",
|
|
26
|
+
"PyYAML>=6.0",
|
|
26
27
|
],
|
|
27
28
|
# Optional dependencies
|
|
28
29
|
extras_require={
|
|
29
30
|
"dev": ["pytest", "black", "flake8"],
|
|
30
|
-
"yaml": ["PyYAML>=6.0"], # For itcpr.yml support
|
|
31
31
|
},
|
|
32
32
|
entry_points={
|
|
33
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
|
|
File without changes
|