git-ssh-sync 0.1.0__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.
@@ -0,0 +1,294 @@
1
+ Metadata-Version: 2.3
2
+ Name: git-ssh-sync
3
+ Version: 0.1.0
4
+ Summary: Sync Git commits through a local machine for development environments without direct GitHub or GitLab access.
5
+ Requires-Dist: pydantic>=2.13.4
6
+ Requires-Dist: pyyaml>=6.0.3
7
+ Requires-Dist: rich>=13.7.0
8
+ Requires-Dist: typer>=0.12.0
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+
12
+ [![日本語](https://img.shields.io/badge/lang-日本語-blue)](README.ja.md) [![English](https://img.shields.io/badge/lang-English-brightgreen)](README.md)
13
+
14
+ # git-ssh-sync
15
+
16
+ [![CI](https://github.com/devgamesan/git-ssh-sync/actions/workflows/ci.yml/badge.svg)](https://github.com/devgamesan/git-ssh-sync/actions/workflows/ci.yml)
17
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
18
+ ![Python](https://img.shields.io/badge/python-3.12+-blue.svg)
19
+ ![Release](https://img.shields.io/github/v/release/devgamesan/git-ssh-sync)
20
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
21
+
22
+ `git-ssh-sync` is a CLI tool for synchronizing Git commits created in a development environment that cannot directly access GitHub/GitLab to external Git services via a local machine.
23
+
24
+ This is not a file synchronization tool. It synchronizes Git objects and branches. Source editing, building, testing, and committing are performed in the development environment, while communication with GitHub/GitLab is handled by the local machine.
25
+
26
+ ## Prerequisites
27
+
28
+ `git-ssh-sync` assumes the following configuration:
29
+
30
+ ```text
31
+ GitHub / GitLab
32
+ ↑↓
33
+ Local machine
34
+ ↑↓ SSH
35
+ Development environment
36
+ ```
37
+
38
+ Local machine:
39
+
40
+ - Can access GitHub / GitLab
41
+ - Can SSH to the development environment
42
+ - Has `git` and `uv` available
43
+ - Uses `git-ssh-sync` for commit synchronization, status checks, and diagnostics between GitHub/GitLab and the development environment
44
+
45
+ Development environment:
46
+
47
+ - Can be accessed via SSH from the local machine
48
+ - Cannot directly access GitHub / GitLab from the development environment
49
+ - Has `git` available
50
+ - Performs source editing, building, testing, and committing
51
+ - Synchronizes with GitHub/GitLab via the local machine
52
+
53
+ ## Installation
54
+
55
+ For normal use, install on your local machine using `uv tool install`.
56
+
57
+ ```bash
58
+ uv tool install git-ssh-sync
59
+ ```
60
+
61
+ For unreleased versions or the latest repository version, install directly from GitHub.
62
+
63
+ ```bash
64
+ uv tool install git+https://github.com/devgamesan/git-ssh-sync.git
65
+ ```
66
+
67
+ After installation, verify that the command can be executed.
68
+
69
+ ```bash
70
+ git-ssh-sync --help
71
+ ```
72
+
73
+ ## Configuration
74
+
75
+ First, register the project you want to synchronize.
76
+
77
+ ```bash
78
+ git-ssh-sync init myproject \
79
+ --origin git@github.com:example/myproject.git \
80
+ --dev-host devserver \
81
+ --dev-user user \
82
+ --dev-path /home/user/work/myproject
83
+ ```
84
+
85
+ Key parameters:
86
+
87
+ - `myproject`: Project name for `git-ssh-sync`
88
+ - `--origin`: Repository URL on the GitHub / GitLab side
89
+ - `--dev-host`: SSH host of the development environment
90
+ - `--dev-user`: SSH user of the development environment
91
+ - `--dev-path`: Path to the work repository on the development environment
92
+
93
+ For `--origin`, specify a remote URL that can be used with `git clone` or `git fetch`. Main formats are:
94
+
95
+ ```text
96
+ git@github.com:example/myproject.git
97
+ git@gitlab.com:example/myproject.git
98
+ ssh://git@github.com/example/myproject.git
99
+ https://github.com/example/myproject.git
100
+ https://gitlab.com/example/myproject.git
101
+ ```
102
+
103
+ When using SSH format, prepare SSH keys and authentication settings for connecting to GitHub/GitLab on the local machine. The development environment does not connect directly to GitHub/GitLab.
104
+
105
+ To overwrite existing configuration, use `--force`.
106
+
107
+ ```bash
108
+ git-ssh-sync init myproject \
109
+ --origin git@github.com:example/myproject.git \
110
+ --dev-host devserver \
111
+ --dev-user user \
112
+ --dev-path /home/user/work/myproject \
113
+ --force
114
+ ```
115
+
116
+ ## Initial Workflow
117
+
118
+ For the first time, execute configuration, clone to the development environment, and diagnostics in order.
119
+
120
+ ```bash
121
+ git-ssh-sync init myproject \
122
+ --origin git@github.com:example/myproject.git \
123
+ --dev-host devserver \
124
+ --dev-user user \
125
+ --dev-path /home/user/work/myproject
126
+ git-ssh-sync clone myproject
127
+ git-ssh-sync doctor myproject
128
+ ```
129
+
130
+ `clone` creates a gateway repository on your local machine and deploys cache and work repositories on the development environment.
131
+
132
+ - Gateway repository: Relay repository on the local machine
133
+ - Cache repository: Bare repository on the development environment
134
+ - Work repository: Repository where actual editing, building, testing, and committing are performed on the development environment
135
+
136
+ Afterward, the work repository on the development environment can be used as a normal Git repository.
137
+
138
+ `doctor` checks the local environment, SSH connection, fetch/push permissions to origin, and repository deployment on the development environment. Run this not only for the first time but also when synchronization is not working properly.
139
+
140
+ ## Daily Development Workflow
141
+
142
+ For daily development, `pull` from the local machine before starting work, commit normally in the development environment, and finally `push` from the local machine.
143
+
144
+ Local machine:
145
+
146
+ ```bash
147
+ git-ssh-sync pull myproject
148
+ ```
149
+
150
+ Development environment:
151
+
152
+ ```bash
153
+ cd ~/work/myproject
154
+ git status
155
+ git add .
156
+ git commit -m "Add feature"
157
+ ```
158
+
159
+ Local machine:
160
+
161
+ ```bash
162
+ git-ssh-sync push myproject
163
+ ```
164
+
165
+ `pull` and `push` target the current branch of the work repository on the development environment. To synchronize a different branch, switch the work repository branch with `checkout` first.
166
+
167
+ ## Branch Switching Workflow
168
+
169
+ To switch to an existing branch, execute `checkout` from the local machine.
170
+
171
+ Local machine:
172
+
173
+ ```bash
174
+ git-ssh-sync checkout myproject feature/foo
175
+ ```
176
+
177
+ To create a new branch, use `-b`. Use `--base` together to explicitly specify the starting point.
178
+
179
+ ```bash
180
+ git-ssh-sync checkout myproject -b feature/foo --base develop
181
+ ```
182
+
183
+ Development environment:
184
+
185
+ ```bash
186
+ cd ~/work/myproject
187
+ git status
188
+ git add .
189
+ git commit -m "Implement foo"
190
+ ```
191
+
192
+ Local machine:
193
+
194
+ ```bash
195
+ git-ssh-sync push myproject
196
+ ```
197
+
198
+ `checkout -b feature/foo --base develop` creates `feature/foo` on origin based on `develop` from origin and switches the work repository on the development environment to that branch. If `--base` is omitted, the current branch of the work repository on the development environment is used as the starting point. If a branch with the same name already exists on origin, switch to the existing branch without `-b`.
199
+
200
+ ## Status Check
201
+
202
+ Use `status` to check synchronization status.
203
+
204
+ ```bash
205
+ git-ssh-sync status myproject
206
+ ```
207
+
208
+ `status` displays the ahead/behind status between origin and the development environment, and the working tree status for the current branch of the work repository. Follow the displayed recommendation and execute `pull` or `push` as necessary.
209
+
210
+ To list existence status and ahead/behind for each branch, use `branch`.
211
+
212
+ ```bash
213
+ git-ssh-sync branch myproject
214
+ ```
215
+
216
+ ## Operational Rules
217
+
218
+ When using `git-ssh-sync`, following these rules makes it easier to understand the state:
219
+
220
+ - `pull` on the local machine before starting work
221
+ - Create commits in the development environment
222
+ - `push` on the local machine when work is done
223
+ - Check `status` when in doubt before/after synchronization
224
+ - Run `doctor` when concerned about connections or repository deployment
225
+
226
+ Uncommitted changes are not synchronized. If there are uncommitted changes in the working tree of the development environment, the changes themselves are not sent to the local machine or origin. Please `git add` and `git commit` changes you want to synchronize in the development environment.
227
+
228
+ `pull` updates the development environment branch only when fast-forward is possible. If origin and the development environment have diverged, automatic merge or automatic rebase is not performed.
229
+
230
+ `push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. If there are unobtained commits on origin, it stops.
231
+
232
+ When diverged, automatic resolution is not performed. Execute `pull` on the local machine, follow the displayed instructions to merge or rebase in the development environment, then `push` again.
233
+
234
+ ## Common Commands
235
+
236
+ ```bash
237
+ # Display help
238
+ git-ssh-sync --help
239
+
240
+ # Register a project
241
+ git-ssh-sync init myproject \
242
+ --origin git@github.com:example/myproject.git \
243
+ --dev-host devserver \
244
+ --dev-user user \
245
+ --dev-path /home/user/work/myproject
246
+
247
+ # Initial clone
248
+ git-ssh-sync clone myproject
249
+
250
+ # Check synchronization status
251
+ git-ssh-sync status myproject
252
+
253
+ # Check branch status
254
+ git-ssh-sync branch myproject
255
+
256
+ # Reflect changes from origin to development environment
257
+ git-ssh-sync pull myproject
258
+
259
+ # Reflect commits from development environment to origin
260
+ git-ssh-sync push myproject
261
+
262
+ # Switch development environment branch
263
+ git-ssh-sync checkout myproject feature/foo
264
+
265
+ # Create and switch to new branch from base branch
266
+ git-ssh-sync checkout myproject -b feature/foo --base develop
267
+
268
+ # Diagnostics
269
+ git-ssh-sync doctor myproject
270
+ ```
271
+
272
+ ## For Developers
273
+
274
+ To develop this repository itself, install dependencies using `uv sync`.
275
+
276
+ ```bash
277
+ uv sync
278
+ ```
279
+
280
+ To execute the CLI during development, you can run it via `uv run`.
281
+
282
+ ```bash
283
+ uv run git-ssh-sync --help
284
+ ```
285
+
286
+ Tests are executed with the following command:
287
+
288
+ ```bash
289
+ uv run pytest
290
+ ```
291
+
292
+ ## Related Documentation
293
+
294
+ - [Specification](docs/spec.md)
@@ -0,0 +1,283 @@
1
+ [![日本語](https://img.shields.io/badge/lang-日本語-blue)](README.ja.md) [![English](https://img.shields.io/badge/lang-English-brightgreen)](README.md)
2
+
3
+ # git-ssh-sync
4
+
5
+ [![CI](https://github.com/devgamesan/git-ssh-sync/actions/workflows/ci.yml/badge.svg)](https://github.com/devgamesan/git-ssh-sync/actions/workflows/ci.yml)
6
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
7
+ ![Python](https://img.shields.io/badge/python-3.12+-blue.svg)
8
+ ![Release](https://img.shields.io/github/v/release/devgamesan/git-ssh-sync)
9
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
10
+
11
+ `git-ssh-sync` is a CLI tool for synchronizing Git commits created in a development environment that cannot directly access GitHub/GitLab to external Git services via a local machine.
12
+
13
+ This is not a file synchronization tool. It synchronizes Git objects and branches. Source editing, building, testing, and committing are performed in the development environment, while communication with GitHub/GitLab is handled by the local machine.
14
+
15
+ ## Prerequisites
16
+
17
+ `git-ssh-sync` assumes the following configuration:
18
+
19
+ ```text
20
+ GitHub / GitLab
21
+ ↑↓
22
+ Local machine
23
+ ↑↓ SSH
24
+ Development environment
25
+ ```
26
+
27
+ Local machine:
28
+
29
+ - Can access GitHub / GitLab
30
+ - Can SSH to the development environment
31
+ - Has `git` and `uv` available
32
+ - Uses `git-ssh-sync` for commit synchronization, status checks, and diagnostics between GitHub/GitLab and the development environment
33
+
34
+ Development environment:
35
+
36
+ - Can be accessed via SSH from the local machine
37
+ - Cannot directly access GitHub / GitLab from the development environment
38
+ - Has `git` available
39
+ - Performs source editing, building, testing, and committing
40
+ - Synchronizes with GitHub/GitLab via the local machine
41
+
42
+ ## Installation
43
+
44
+ For normal use, install on your local machine using `uv tool install`.
45
+
46
+ ```bash
47
+ uv tool install git-ssh-sync
48
+ ```
49
+
50
+ For unreleased versions or the latest repository version, install directly from GitHub.
51
+
52
+ ```bash
53
+ uv tool install git+https://github.com/devgamesan/git-ssh-sync.git
54
+ ```
55
+
56
+ After installation, verify that the command can be executed.
57
+
58
+ ```bash
59
+ git-ssh-sync --help
60
+ ```
61
+
62
+ ## Configuration
63
+
64
+ First, register the project you want to synchronize.
65
+
66
+ ```bash
67
+ git-ssh-sync init myproject \
68
+ --origin git@github.com:example/myproject.git \
69
+ --dev-host devserver \
70
+ --dev-user user \
71
+ --dev-path /home/user/work/myproject
72
+ ```
73
+
74
+ Key parameters:
75
+
76
+ - `myproject`: Project name for `git-ssh-sync`
77
+ - `--origin`: Repository URL on the GitHub / GitLab side
78
+ - `--dev-host`: SSH host of the development environment
79
+ - `--dev-user`: SSH user of the development environment
80
+ - `--dev-path`: Path to the work repository on the development environment
81
+
82
+ For `--origin`, specify a remote URL that can be used with `git clone` or `git fetch`. Main formats are:
83
+
84
+ ```text
85
+ git@github.com:example/myproject.git
86
+ git@gitlab.com:example/myproject.git
87
+ ssh://git@github.com/example/myproject.git
88
+ https://github.com/example/myproject.git
89
+ https://gitlab.com/example/myproject.git
90
+ ```
91
+
92
+ When using SSH format, prepare SSH keys and authentication settings for connecting to GitHub/GitLab on the local machine. The development environment does not connect directly to GitHub/GitLab.
93
+
94
+ To overwrite existing configuration, use `--force`.
95
+
96
+ ```bash
97
+ git-ssh-sync init myproject \
98
+ --origin git@github.com:example/myproject.git \
99
+ --dev-host devserver \
100
+ --dev-user user \
101
+ --dev-path /home/user/work/myproject \
102
+ --force
103
+ ```
104
+
105
+ ## Initial Workflow
106
+
107
+ For the first time, execute configuration, clone to the development environment, and diagnostics in order.
108
+
109
+ ```bash
110
+ git-ssh-sync init myproject \
111
+ --origin git@github.com:example/myproject.git \
112
+ --dev-host devserver \
113
+ --dev-user user \
114
+ --dev-path /home/user/work/myproject
115
+ git-ssh-sync clone myproject
116
+ git-ssh-sync doctor myproject
117
+ ```
118
+
119
+ `clone` creates a gateway repository on your local machine and deploys cache and work repositories on the development environment.
120
+
121
+ - Gateway repository: Relay repository on the local machine
122
+ - Cache repository: Bare repository on the development environment
123
+ - Work repository: Repository where actual editing, building, testing, and committing are performed on the development environment
124
+
125
+ Afterward, the work repository on the development environment can be used as a normal Git repository.
126
+
127
+ `doctor` checks the local environment, SSH connection, fetch/push permissions to origin, and repository deployment on the development environment. Run this not only for the first time but also when synchronization is not working properly.
128
+
129
+ ## Daily Development Workflow
130
+
131
+ For daily development, `pull` from the local machine before starting work, commit normally in the development environment, and finally `push` from the local machine.
132
+
133
+ Local machine:
134
+
135
+ ```bash
136
+ git-ssh-sync pull myproject
137
+ ```
138
+
139
+ Development environment:
140
+
141
+ ```bash
142
+ cd ~/work/myproject
143
+ git status
144
+ git add .
145
+ git commit -m "Add feature"
146
+ ```
147
+
148
+ Local machine:
149
+
150
+ ```bash
151
+ git-ssh-sync push myproject
152
+ ```
153
+
154
+ `pull` and `push` target the current branch of the work repository on the development environment. To synchronize a different branch, switch the work repository branch with `checkout` first.
155
+
156
+ ## Branch Switching Workflow
157
+
158
+ To switch to an existing branch, execute `checkout` from the local machine.
159
+
160
+ Local machine:
161
+
162
+ ```bash
163
+ git-ssh-sync checkout myproject feature/foo
164
+ ```
165
+
166
+ To create a new branch, use `-b`. Use `--base` together to explicitly specify the starting point.
167
+
168
+ ```bash
169
+ git-ssh-sync checkout myproject -b feature/foo --base develop
170
+ ```
171
+
172
+ Development environment:
173
+
174
+ ```bash
175
+ cd ~/work/myproject
176
+ git status
177
+ git add .
178
+ git commit -m "Implement foo"
179
+ ```
180
+
181
+ Local machine:
182
+
183
+ ```bash
184
+ git-ssh-sync push myproject
185
+ ```
186
+
187
+ `checkout -b feature/foo --base develop` creates `feature/foo` on origin based on `develop` from origin and switches the work repository on the development environment to that branch. If `--base` is omitted, the current branch of the work repository on the development environment is used as the starting point. If a branch with the same name already exists on origin, switch to the existing branch without `-b`.
188
+
189
+ ## Status Check
190
+
191
+ Use `status` to check synchronization status.
192
+
193
+ ```bash
194
+ git-ssh-sync status myproject
195
+ ```
196
+
197
+ `status` displays the ahead/behind status between origin and the development environment, and the working tree status for the current branch of the work repository. Follow the displayed recommendation and execute `pull` or `push` as necessary.
198
+
199
+ To list existence status and ahead/behind for each branch, use `branch`.
200
+
201
+ ```bash
202
+ git-ssh-sync branch myproject
203
+ ```
204
+
205
+ ## Operational Rules
206
+
207
+ When using `git-ssh-sync`, following these rules makes it easier to understand the state:
208
+
209
+ - `pull` on the local machine before starting work
210
+ - Create commits in the development environment
211
+ - `push` on the local machine when work is done
212
+ - Check `status` when in doubt before/after synchronization
213
+ - Run `doctor` when concerned about connections or repository deployment
214
+
215
+ Uncommitted changes are not synchronized. If there are uncommitted changes in the working tree of the development environment, the changes themselves are not sent to the local machine or origin. Please `git add` and `git commit` changes you want to synchronize in the development environment.
216
+
217
+ `pull` updates the development environment branch only when fast-forward is possible. If origin and the development environment have diverged, automatic merge or automatic rebase is not performed.
218
+
219
+ `push` executes only when the branch on the origin side is an ancestor of the branch on the development environment side. If there are unobtained commits on origin, it stops.
220
+
221
+ When diverged, automatic resolution is not performed. Execute `pull` on the local machine, follow the displayed instructions to merge or rebase in the development environment, then `push` again.
222
+
223
+ ## Common Commands
224
+
225
+ ```bash
226
+ # Display help
227
+ git-ssh-sync --help
228
+
229
+ # Register a project
230
+ git-ssh-sync init myproject \
231
+ --origin git@github.com:example/myproject.git \
232
+ --dev-host devserver \
233
+ --dev-user user \
234
+ --dev-path /home/user/work/myproject
235
+
236
+ # Initial clone
237
+ git-ssh-sync clone myproject
238
+
239
+ # Check synchronization status
240
+ git-ssh-sync status myproject
241
+
242
+ # Check branch status
243
+ git-ssh-sync branch myproject
244
+
245
+ # Reflect changes from origin to development environment
246
+ git-ssh-sync pull myproject
247
+
248
+ # Reflect commits from development environment to origin
249
+ git-ssh-sync push myproject
250
+
251
+ # Switch development environment branch
252
+ git-ssh-sync checkout myproject feature/foo
253
+
254
+ # Create and switch to new branch from base branch
255
+ git-ssh-sync checkout myproject -b feature/foo --base develop
256
+
257
+ # Diagnostics
258
+ git-ssh-sync doctor myproject
259
+ ```
260
+
261
+ ## For Developers
262
+
263
+ To develop this repository itself, install dependencies using `uv sync`.
264
+
265
+ ```bash
266
+ uv sync
267
+ ```
268
+
269
+ To execute the CLI during development, you can run it via `uv run`.
270
+
271
+ ```bash
272
+ uv run git-ssh-sync --help
273
+ ```
274
+
275
+ Tests are executed with the following command:
276
+
277
+ ```bash
278
+ uv run pytest
279
+ ```
280
+
281
+ ## Related Documentation
282
+
283
+ - [Specification](docs/spec.md)
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "git-ssh-sync"
3
+ version = "0.1.0"
4
+ description = "Sync Git commits through a local machine for development environments without direct GitHub or GitLab access."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "pydantic>=2.13.4",
9
+ "pyyaml>=6.0.3",
10
+ "rich>=13.7.0",
11
+ "typer>=0.12.0",
12
+ ]
13
+
14
+ [project.scripts]
15
+ git-ssh-sync = "git_ssh_sync.cli:main"
16
+
17
+ [dependency-groups]
18
+ dev = [
19
+ "pytest>=8.0.0",
20
+ "ruff>=0.15.18",
21
+ ]
22
+
23
+ [build-system]
24
+ requires = ["uv_build>=0.8.0,<0.9.0"]
25
+ build-backend = "uv_build"
26
+
27
+ [tool.pytest.ini_options]
28
+ testpaths = ["tests"]
29
+ pythonpath = ["src"]
30
+
31
+ [tool.ruff]
32
+ target-version = "py312"
33
+ src = ["src", "tests"]
@@ -0,0 +1,3 @@
1
+ """git-ssh-sync package."""
2
+
3
+ __version__ = "0.1.0"