git-remote-dropbox 2.0.4__tar.gz → 2.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.
- git_remote_dropbox-2.1.0/.github/workflows/ci.yml +54 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/CONTRIBUTING.md +6 -1
- git_remote_dropbox-2.1.0/DEVELOPMENT.md +78 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/PKG-INFO +12 -5
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/README.md +10 -3
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/pyproject.toml +9 -3
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/__init__.py +1 -1
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/manage.py +6 -4
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/constants.py +1 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/helper.py +2 -2
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/util.py +30 -22
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/tests/test-lib.sh +1 -1
- git_remote_dropbox-2.0.4/.github/workflows/build.yml +0 -44
- git_remote_dropbox-2.0.4/tests/README.md +0 -22
- git_remote_dropbox-2.0.4/tests/Vagrantfile +0 -27
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/.editorconfig +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/.gitignore +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/DESIGN.md +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/LICENSE.md +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/__init__.py +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/common.py +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/helper.py +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/git.py +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/tests/.gitignore +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/tests/dropbox_delete.py +0 -0
- {git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/tests/test.sh +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
schedule:
|
|
5
|
+
- cron: '0 8 * * 6'
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-22.04
|
|
9
|
+
environment: main
|
|
10
|
+
strategy:
|
|
11
|
+
matrix:
|
|
12
|
+
python: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
13
|
+
name: "Test: Python ${{ matrix.python }}"
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v7
|
|
16
|
+
- uses: actions/setup-python@v6
|
|
17
|
+
with:
|
|
18
|
+
python-version: ${{ matrix.python }}
|
|
19
|
+
- run: |
|
|
20
|
+
python -m pip install --upgrade pip
|
|
21
|
+
- run: pip install .
|
|
22
|
+
- run: ./tests/test.sh
|
|
23
|
+
env:
|
|
24
|
+
DROPBOX_TOKEN: ${{ secrets.DROPBOX_TOKEN }}
|
|
25
|
+
typecheck:
|
|
26
|
+
name: Type check
|
|
27
|
+
runs-on: ubuntu-24.04
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v7
|
|
30
|
+
- uses: actions/setup-python@v6
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.14"
|
|
33
|
+
- uses: pypa/hatch@install
|
|
34
|
+
- run: hatch run types:check
|
|
35
|
+
fmt:
|
|
36
|
+
name: Format
|
|
37
|
+
runs-on: ubuntu-24.04
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v7
|
|
40
|
+
- uses: actions/setup-python@v6
|
|
41
|
+
with:
|
|
42
|
+
python-version: "3.14"
|
|
43
|
+
- uses: pypa/hatch@install
|
|
44
|
+
- run: hatch check fmt
|
|
45
|
+
lint:
|
|
46
|
+
name: Lint
|
|
47
|
+
runs-on: ubuntu-24.04
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v7
|
|
50
|
+
- uses: actions/setup-python@v6
|
|
51
|
+
with:
|
|
52
|
+
python-version: "3.14"
|
|
53
|
+
- uses: pypa/hatch@install
|
|
54
|
+
- run: hatch check code
|
|
@@ -48,7 +48,11 @@ substantial changes to the code base, it is *highly recommended* that you first
|
|
|
48
48
|
Any changes to the code base should follow the style and coding conventions
|
|
49
49
|
used in the rest of the project. The version history should be clean, and
|
|
50
50
|
commit messages should be descriptive and [properly
|
|
51
|
-
formatted][commit-messages].
|
|
51
|
+
formatted][commit-messages]. It's recommended that you add unit tests to
|
|
52
|
+
demonstrate that the bug is fixed (or that the feature works).
|
|
53
|
+
|
|
54
|
+
See the [git-remote-dropbox development guide][development] to learn how to run
|
|
55
|
+
the tests, type checking, and more.
|
|
52
56
|
|
|
53
57
|
---
|
|
54
58
|
|
|
@@ -61,3 +65,4 @@ If you have any questions about anything, feel free to [ask][email]!
|
|
|
61
65
|
[email]: mailto:me@anishathalye.com
|
|
62
66
|
[gitremote-helpers]: https://www.kernel.org/pub/software/scm/git/docs/gitremote-helpers.html
|
|
63
67
|
[commit-messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
|
68
|
+
[development]: DEVELOPMENT.md
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
git-remote-dropbox uses the [Hatch] project manager ([installation instructions][hatch-install]).
|
|
4
|
+
|
|
5
|
+
Hatch automatically manages dependencies and runs type checking, formatting/linting, and other operations in isolated [environments][hatch-environments].
|
|
6
|
+
|
|
7
|
+
[Hatch]: https://hatch.pypa.io/
|
|
8
|
+
[hatch-install]: https://hatch.pypa.io/latest/install/
|
|
9
|
+
[hatch-environments]: https://hatch.pypa.io/latest/environment/
|
|
10
|
+
|
|
11
|
+
## Testing
|
|
12
|
+
|
|
13
|
+
git-remote-dropbox has integration tests written in shell scripts. The tests exercise git-remote-dropbox via git operations, so the tests interact with the filesystem. For this reason, it is recommended that tests are run inside a Docker container (or in CI).
|
|
14
|
+
|
|
15
|
+
To run the tests, first start a Docker container:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
docker run -it --rm -v "${PWD}:/git-remote-dropbox" -w /git-remote-dropbox python:3.13-bookworm /bin/bash
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Now, inside the Docker container, install the git-remote-dropbox package:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Next, set the `DROPBOX_TOKEN` environment variable (to your long-lived access token). This is required because the tests actually interact with the real Dropbox API.
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
export DROPBOX_TOKEN='...'
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Finally, run the tests:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
tests/test.sh
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Type checking
|
|
40
|
+
|
|
41
|
+
You can run the [mypy static type checker][mypy] with:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
hatch run types:check
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
[mypy]: https://mypy-lang.org/
|
|
48
|
+
|
|
49
|
+
## Formatting and linting
|
|
50
|
+
|
|
51
|
+
You can run the [Ruff][ruff] formatter and linter with:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
hatch fmt
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This will automatically make [safe fixes][fix-safety] to your code. If you want to only check your files without making modifications, run `hatch fmt --check`.
|
|
58
|
+
|
|
59
|
+
[ruff]: https://github.com/astral-sh/ruff
|
|
60
|
+
[fix-safety]: https://docs.astral.sh/ruff/linter/#fix-safety
|
|
61
|
+
|
|
62
|
+
## Packaging
|
|
63
|
+
|
|
64
|
+
You can use [`hatch build`][hatch-build] to create build artifacts, a [source distribution ("sdist")][sdist] and a [built distribution ("wheel")][bdist].
|
|
65
|
+
|
|
66
|
+
You can use [`hatch publish`][hatch-publish] to publish build artifacts to [PyPI][pypi].
|
|
67
|
+
|
|
68
|
+
[hatch-build]: https://hatch.pypa.io/latest/build/
|
|
69
|
+
[sdist]: https://packaging.python.org/en/latest/glossary/#term-Source-Distribution-or-sdist
|
|
70
|
+
[bdist]: https://packaging.python.org/en/latest/glossary/#term-Built-Distribution
|
|
71
|
+
[hatch-publish]: https://hatch.pypa.io/latest/publish/
|
|
72
|
+
[pypi]: https://pypi.org/
|
|
73
|
+
|
|
74
|
+
## Continuous integration
|
|
75
|
+
|
|
76
|
+
Testing, type checking, and formatting/linting is [checked in CI][ci].
|
|
77
|
+
|
|
78
|
+
[ci]: .github/workflows/ci.yml
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: git-remote-dropbox
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: A transparent bidirectional bridge between Git and Dropbox
|
|
5
5
|
Project-URL: homepage, https://github.com/anishathalye/git-remote-dropbox
|
|
6
6
|
Project-URL: repository, https://github.com/anishathalye/git-remote-dropbox.git
|
|
@@ -13,11 +13,11 @@ Classifier: Intended Audience :: Developers
|
|
|
13
13
|
Classifier: License :: OSI Approved :: MIT License
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Topic :: Software Development :: Version Control
|
|
16
|
-
Requires-Python: >=3.
|
|
16
|
+
Requires-Python: >=3.7
|
|
17
17
|
Requires-Dist: dropbox<13,>=12
|
|
18
18
|
Description-Content-Type: text/markdown
|
|
19
19
|
|
|
20
|
-
# git-remote-dropbox [](https://github.com/anishathalye/git-remote-dropbox/actions/workflows/ci.yml) [](https://pypi.org/pypi/git-remote-dropbox/)
|
|
21
21
|
|
|
22
22
|
git-remote-dropbox is a transparent bidirectional bridge between Git and
|
|
23
23
|
Dropbox. It lets you use a Dropbox folder or a shared folder as a Git remote!
|
|
@@ -58,15 +58,22 @@ concurrent operations, even when using a shared folder.
|
|
|
58
58
|
### Install git-remote-dropbox
|
|
59
59
|
|
|
60
60
|
1. Prerequisites:
|
|
61
|
-
1. `
|
|
61
|
+
1. [`uv`](https://docs.astral.sh/uv/) (or other tool like `pip`)
|
|
62
62
|
2. `git`
|
|
63
|
-
2. Install this package with `
|
|
63
|
+
2. Install this package with `uv tool install git-remote-dropbox`. Use `which git-remote-dropbox` to make sure it's available via `$PATH`.
|
|
64
64
|
|
|
65
65
|
### Log in to Dropbox
|
|
66
66
|
|
|
67
67
|
Run `git dropbox login` and follow the instructions to authenticate with OAuth
|
|
68
68
|
and log in to your Dropbox account.
|
|
69
69
|
|
|
70
|
+
If you'd like to scope the access to an [app
|
|
71
|
+
folder](https://help.dropbox.com/integrations/third-party-apps), you can run
|
|
72
|
+
`git dropbox login --app-folder`. With this setup, paths will be rooted in a
|
|
73
|
+
"git-remote-dropbox repos" [app folder in your Dropbox
|
|
74
|
+
account](https://www.dropbox.com/home/Apps). Note that app folders [**cannot be
|
|
75
|
+
shared**](https://community.dropbox.com/en/discussion/38534/sharing-of-folders-inside-the-apps-folder).
|
|
76
|
+
|
|
70
77
|
## Sharing
|
|
71
78
|
|
|
72
79
|
The above gives you a way to create a Git repository on Dropbox and use it from multiple machines that you own. In other words, it's a convenient way to share a remote with your laptop and your desktop.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# git-remote-dropbox [](https://github.com/anishathalye/git-remote-dropbox/actions/workflows/ci.yml) [](https://pypi.org/pypi/git-remote-dropbox/)
|
|
2
2
|
|
|
3
3
|
git-remote-dropbox is a transparent bidirectional bridge between Git and
|
|
4
4
|
Dropbox. It lets you use a Dropbox folder or a shared folder as a Git remote!
|
|
@@ -39,15 +39,22 @@ concurrent operations, even when using a shared folder.
|
|
|
39
39
|
### Install git-remote-dropbox
|
|
40
40
|
|
|
41
41
|
1. Prerequisites:
|
|
42
|
-
1. `
|
|
42
|
+
1. [`uv`](https://docs.astral.sh/uv/) (or other tool like `pip`)
|
|
43
43
|
2. `git`
|
|
44
|
-
2. Install this package with `
|
|
44
|
+
2. Install this package with `uv tool install git-remote-dropbox`. Use `which git-remote-dropbox` to make sure it's available via `$PATH`.
|
|
45
45
|
|
|
46
46
|
### Log in to Dropbox
|
|
47
47
|
|
|
48
48
|
Run `git dropbox login` and follow the instructions to authenticate with OAuth
|
|
49
49
|
and log in to your Dropbox account.
|
|
50
50
|
|
|
51
|
+
If you'd like to scope the access to an [app
|
|
52
|
+
folder](https://help.dropbox.com/integrations/third-party-apps), you can run
|
|
53
|
+
`git dropbox login --app-folder`. With this setup, paths will be rooted in a
|
|
54
|
+
"git-remote-dropbox repos" [app folder in your Dropbox
|
|
55
|
+
account](https://www.dropbox.com/home/Apps). Note that app folders [**cannot be
|
|
56
|
+
shared**](https://community.dropbox.com/en/discussion/38534/sharing-of-folders-inside-the-apps-folder).
|
|
57
|
+
|
|
51
58
|
## Sharing
|
|
52
59
|
|
|
53
60
|
The above gives you a way to create a Git repository on Dropbox and use it from multiple machines that you own. In other words, it's a convenient way to share a remote with your laptop and your desktop.
|
|
@@ -9,7 +9,7 @@ authors = [
|
|
|
9
9
|
]
|
|
10
10
|
description = "A transparent bidirectional bridge between Git and Dropbox"
|
|
11
11
|
readme = "README.md"
|
|
12
|
-
requires-python = ">=3.
|
|
12
|
+
requires-python = ">=3.7"
|
|
13
13
|
classifiers = [
|
|
14
14
|
"Development Status :: 5 - Production/Stable",
|
|
15
15
|
"Intended Audience :: Developers",
|
|
@@ -38,13 +38,19 @@ issues = "https://github.com/anishathalye/git-remote-dropbox/issues"
|
|
|
38
38
|
[tool.hatch.version]
|
|
39
39
|
path = "src/git_remote_dropbox/__init__.py"
|
|
40
40
|
|
|
41
|
+
[tool.hatch.envs.default]
|
|
42
|
+
installer = "uv"
|
|
43
|
+
|
|
41
44
|
[tool.hatch.envs.types]
|
|
42
45
|
extra-dependencies = [
|
|
43
|
-
"mypy>=
|
|
46
|
+
"mypy>=2.0.0",
|
|
44
47
|
]
|
|
45
48
|
|
|
46
49
|
[tool.hatch.envs.types.scripts]
|
|
47
|
-
check = "mypy
|
|
50
|
+
check = "mypy {args:src tests}"
|
|
51
|
+
|
|
52
|
+
[tool.mypy]
|
|
53
|
+
strict = true
|
|
48
54
|
|
|
49
55
|
[tool.ruff.lint]
|
|
50
56
|
ignore = [
|
|
@@ -34,6 +34,7 @@ def main() -> None:
|
|
|
34
34
|
|
|
35
35
|
parser_login = subparsers.add_parser("login", help="log in to Dropbox")
|
|
36
36
|
parser_login.add_argument("username", type=str, help="username/tag", nargs="?", default=None)
|
|
37
|
+
parser_login.add_argument("--app-folder", action="store_true", help="scope access to an app-specific folder")
|
|
37
38
|
|
|
38
39
|
parser_logout = subparsers.add_parser("logout", help="log out from Dropbox")
|
|
39
40
|
parser_logout.add_argument("username", type=str, help="username/tag", nargs="?", default=None)
|
|
@@ -49,7 +50,7 @@ def main() -> None:
|
|
|
49
50
|
elif args.command == "version":
|
|
50
51
|
version()
|
|
51
52
|
elif args.command == "login":
|
|
52
|
-
login(args.username)
|
|
53
|
+
login(args.username, app_folder=args.app_folder)
|
|
53
54
|
elif args.command == "logout":
|
|
54
55
|
logout(args.username)
|
|
55
56
|
elif args.command == "show-logins":
|
|
@@ -99,9 +100,10 @@ def set_head(remote: str, branch: str) -> None:
|
|
|
99
100
|
print(f"Updated remote HEAD to '{remote_ref}'.")
|
|
100
101
|
|
|
101
102
|
|
|
102
|
-
def login(username: Optional[str]) -> None:
|
|
103
|
+
def login(username: Optional[str], *, app_folder: bool) -> None:
|
|
104
|
+
app_key = constants.APP_FOLDER_APP_KEY if app_folder else constants.APP_KEY
|
|
103
105
|
auth_flow = dropbox.DropboxOAuth2FlowNoRedirect(
|
|
104
|
-
|
|
106
|
+
app_key,
|
|
105
107
|
use_pkce=True,
|
|
106
108
|
token_access_type="offline", # noqa: S106
|
|
107
109
|
)
|
|
@@ -113,7 +115,7 @@ def login(username: Optional[str]) -> None:
|
|
|
113
115
|
auth_code = input("Enter authorization code: ").strip()
|
|
114
116
|
try:
|
|
115
117
|
oauth_result = auth_flow.finish(auth_code)
|
|
116
|
-
token = RefreshToken(oauth_result.refresh_token)
|
|
118
|
+
token = RefreshToken(oauth_result.refresh_token, app_key)
|
|
117
119
|
except Exception: # noqa: BLE001
|
|
118
120
|
error("failed to log in; did you copy the code correctly?")
|
|
119
121
|
|
|
@@ -150,7 +150,7 @@ class Helper:
|
|
|
150
150
|
self._delete(dst)
|
|
151
151
|
else:
|
|
152
152
|
self._push(src, dst)
|
|
153
|
-
if self._first_push and (not remote_head or src == git.
|
|
153
|
+
if self._first_push and (not remote_head or src == git.symbolic_ref_value("HEAD")):
|
|
154
154
|
remote_head = dst
|
|
155
155
|
line = readline()
|
|
156
156
|
if line == "":
|
|
@@ -169,7 +169,7 @@ class Helper:
|
|
|
169
169
|
Handle the fetch command.
|
|
170
170
|
"""
|
|
171
171
|
while True:
|
|
172
|
-
_, sha,
|
|
172
|
+
_, sha, _ = line.split(" ")
|
|
173
173
|
self._fetch(sha)
|
|
174
174
|
line = readline()
|
|
175
175
|
if line == "":
|
|
@@ -40,7 +40,7 @@ def stdout_to_binary() -> None:
|
|
|
40
40
|
Ensure that stdout is in binary mode on windows
|
|
41
41
|
"""
|
|
42
42
|
if sys.platform == "win32":
|
|
43
|
-
import msvcrt
|
|
43
|
+
import msvcrt # noqa: PLC0415
|
|
44
44
|
|
|
45
45
|
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
|
|
46
46
|
|
|
@@ -130,27 +130,34 @@ class Token(ABC):
|
|
|
130
130
|
|
|
131
131
|
class RefreshToken(Token):
|
|
132
132
|
_value: str
|
|
133
|
+
_app_key: str
|
|
133
134
|
|
|
134
|
-
def __init__(self, value: str) -> None:
|
|
135
|
+
def __init__(self, value: str, app_key: str) -> None:
|
|
135
136
|
self._value = value
|
|
137
|
+
self._app_key = app_key
|
|
136
138
|
|
|
137
139
|
def serialize(self) -> Any:
|
|
138
|
-
return ["refresh", self._value]
|
|
140
|
+
return ["refresh", self._value, self._app_key]
|
|
139
141
|
|
|
140
142
|
@classmethod
|
|
141
143
|
def parse(cls, rep: Any) -> "RefreshToken":
|
|
144
|
+
# v2 style
|
|
145
|
+
if isinstance(rep, list) and len(rep) == 2 and rep[0] == "refresh" and isinstance(rep[1], str): # noqa: PLR2004
|
|
146
|
+
return RefreshToken(rep[1], APP_KEY)
|
|
147
|
+
# v3 style
|
|
142
148
|
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
149
|
+
isinstance(rep, list)
|
|
150
|
+
and len(rep) == 3 # noqa: PLR2004
|
|
151
|
+
and rep[0] == "refresh"
|
|
152
|
+
and isinstance(rep[1], str)
|
|
153
|
+
and isinstance(rep[2], str)
|
|
147
154
|
):
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
155
|
+
return RefreshToken(rep[1], rep[2])
|
|
156
|
+
msg = "cannot parse as RefreshToken"
|
|
157
|
+
raise ValueError(msg)
|
|
151
158
|
|
|
152
159
|
def connect(self) -> dropbox.Dropbox:
|
|
153
|
-
return dropbox.Dropbox(oauth2_refresh_token=self._value, app_key=
|
|
160
|
+
return dropbox.Dropbox(oauth2_refresh_token=self._value, app_key=self._app_key)
|
|
154
161
|
|
|
155
162
|
|
|
156
163
|
class LongLivedToken(Token):
|
|
@@ -179,7 +186,7 @@ class LongLivedToken(Token):
|
|
|
179
186
|
|
|
180
187
|
|
|
181
188
|
def parse_token(rep: Any) -> Token:
|
|
182
|
-
for token_type in
|
|
189
|
+
for token_type in (RefreshToken, LongLivedToken):
|
|
183
190
|
try:
|
|
184
191
|
return token_type.parse(rep)
|
|
185
192
|
except ValueError:
|
|
@@ -193,7 +200,7 @@ class Config:
|
|
|
193
200
|
A class to manage configuration data.
|
|
194
201
|
"""
|
|
195
202
|
|
|
196
|
-
_VERSION: int =
|
|
203
|
+
_VERSION: int = 3
|
|
197
204
|
|
|
198
205
|
_filename: str
|
|
199
206
|
_default_token: Optional[Token]
|
|
@@ -221,7 +228,11 @@ class Config:
|
|
|
221
228
|
with open(self._filename) as f:
|
|
222
229
|
rep = json.load(f)
|
|
223
230
|
version = rep.get("version")
|
|
224
|
-
#
|
|
231
|
+
# cannot parse future versions
|
|
232
|
+
if version is not None and (not isinstance(version, int) or version > self._VERSION):
|
|
233
|
+
msg = f'expected config version <= {self._VERSION}, got {version}; upgrade git-remote-dropbox or delete the config file "{self._filename}" to re-initialize'
|
|
234
|
+
raise ValueError(msg)
|
|
235
|
+
# support all past versions
|
|
225
236
|
if version is None:
|
|
226
237
|
# v1 style config, before we had versions
|
|
227
238
|
for username, token_rep in rep.items():
|
|
@@ -230,19 +241,16 @@ class Config:
|
|
|
230
241
|
self._default_token = token
|
|
231
242
|
else:
|
|
232
243
|
self._named_tokens[username] = token
|
|
233
|
-
self.save()
|
|
234
|
-
elif version != self._VERSION:
|
|
235
|
-
raise ValueError(
|
|
236
|
-
'expected config version %d, got %s; delete the config file "%s" to re-initialize'
|
|
237
|
-
% (self._VERSION, version, self._filename)
|
|
238
|
-
)
|
|
239
244
|
else:
|
|
240
|
-
#
|
|
245
|
+
# current parser supports parsing as v2 or v3 style config
|
|
241
246
|
default_token_rep = rep["tokens"]["default"]
|
|
242
247
|
if default_token_rep:
|
|
243
248
|
self._default_token = parse_token(default_token_rep)
|
|
244
249
|
for username, token_rep in rep["tokens"]["named"].items():
|
|
245
250
|
self._named_tokens[username] = parse_token(token_rep)
|
|
251
|
+
# upgrade file on disk if necessary
|
|
252
|
+
if version != self._VERSION:
|
|
253
|
+
self.save()
|
|
246
254
|
|
|
247
255
|
def get_default_token(self) -> Optional[Token]:
|
|
248
256
|
return self._default_token
|
|
@@ -269,7 +277,7 @@ class Config:
|
|
|
269
277
|
def atomic_write(contents: bytes, path: str) -> None:
|
|
270
278
|
# same directory as path to avoid being on a different filesystem
|
|
271
279
|
try:
|
|
272
|
-
temp_file = tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False)
|
|
280
|
+
temp_file = tempfile.NamedTemporaryFile(dir=os.path.dirname(path), delete=False) # noqa: SIM115
|
|
273
281
|
temp_file.write(contents)
|
|
274
282
|
temp_file.flush()
|
|
275
283
|
os.fsync(temp_file.fileno())
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
name: CI
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
schedule:
|
|
5
|
-
- cron: '0 8 * * 6'
|
|
6
|
-
jobs:
|
|
7
|
-
test:
|
|
8
|
-
runs-on: ubuntu-20.04
|
|
9
|
-
environment: main
|
|
10
|
-
strategy:
|
|
11
|
-
matrix:
|
|
12
|
-
python: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
13
|
-
name: "Test: Python ${{ matrix.python }}"
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
- uses: actions/setup-python@v5
|
|
17
|
-
with:
|
|
18
|
-
python-version: ${{ matrix.python }}
|
|
19
|
-
- run: |
|
|
20
|
-
python -m pip install --upgrade pip
|
|
21
|
-
- run: pip install .
|
|
22
|
-
- run: ./tests/test.sh
|
|
23
|
-
env:
|
|
24
|
-
DROPBOX_TOKEN: ${{ secrets.DROPBOX_TOKEN }}
|
|
25
|
-
typecheck:
|
|
26
|
-
name: Type check
|
|
27
|
-
runs-on: ubuntu-24.04
|
|
28
|
-
steps:
|
|
29
|
-
- uses: actions/checkout@v4
|
|
30
|
-
- uses: actions/setup-python@v5
|
|
31
|
-
with:
|
|
32
|
-
python-version: "3.13"
|
|
33
|
-
- uses: pypa/hatch@install
|
|
34
|
-
- run: hatch run types:check
|
|
35
|
-
fmt:
|
|
36
|
-
name: Format and lint
|
|
37
|
-
runs-on: ubuntu-24.04
|
|
38
|
-
steps:
|
|
39
|
-
- uses: actions/checkout@v4
|
|
40
|
-
- uses: actions/setup-python@v5
|
|
41
|
-
with:
|
|
42
|
-
python-version: "3.13"
|
|
43
|
-
- uses: pypa/hatch@install
|
|
44
|
-
- run: hatch fmt --check
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Testing
|
|
2
|
-
|
|
3
|
-
When running tests locally, git-remote-dropbox uses [Vagrant] to run tests
|
|
4
|
-
inside a virtual machine to completely isolate tests from the host machine.
|
|
5
|
-
|
|
6
|
-
## Running the tests
|
|
7
|
-
|
|
8
|
-
Start the VM using `vagrant up`, and SSH into the VM using `vagrant ssh`. The
|
|
9
|
-
rest of the commands should be run in the VM.
|
|
10
|
-
|
|
11
|
-
The test script requires a Dropbox token to run, because it actually interacts
|
|
12
|
-
with the real Dropbox API during the test.
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
cd /git-remote-dropbox
|
|
16
|
-
pip3 install -e .
|
|
17
|
-
cd test
|
|
18
|
-
export DROPBOX_TOKEN='...'
|
|
19
|
-
./test.sh
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
[Vagrant]: https://www.vagrantup.com/
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
Vagrant.configure(2) do |config|
|
|
2
|
-
|
|
3
|
-
config.vm.box = 'ubuntu/bionic64'
|
|
4
|
-
|
|
5
|
-
# synced folder
|
|
6
|
-
config.vm.synced_folder '..', '/git-remote-dropbox'
|
|
7
|
-
|
|
8
|
-
# disable default synced folder
|
|
9
|
-
config.vm.synced_folder '.', '/vagrant', disabled: true
|
|
10
|
-
|
|
11
|
-
# install packages
|
|
12
|
-
config.vm.provision 'shell', inline: <<-EOS
|
|
13
|
-
apt-get -y update
|
|
14
|
-
apt-get install -y git python3-pip
|
|
15
|
-
EOS
|
|
16
|
-
|
|
17
|
-
# alias python -> python3
|
|
18
|
-
config.vm.provision 'shell', inline: <<-EOS
|
|
19
|
-
sudo ln -s /usr/bin/python3 /usr/bin/python
|
|
20
|
-
EOS
|
|
21
|
-
|
|
22
|
-
# configure PATH
|
|
23
|
-
config.vm.provision 'shell', inline: <<-EOS
|
|
24
|
-
echo 'PATH=$HOME/.local/bin:$PATH' > /etc/profile.d/path.sh
|
|
25
|
-
EOS
|
|
26
|
-
|
|
27
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{git_remote_dropbox-2.0.4 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|