git-remote-dropbox 2.0.5__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.
Files changed (24) hide show
  1. git_remote_dropbox-2.1.0/.github/workflows/ci.yml +54 -0
  2. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/PKG-INFO +11 -4
  3. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/README.md +9 -2
  4. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/pyproject.toml +9 -3
  5. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/__init__.py +1 -1
  6. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/manage.py +6 -4
  7. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/constants.py +1 -0
  8. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/helper.py +1 -1
  9. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/util.py +30 -22
  10. git_remote_dropbox-2.0.5/.github/workflows/ci.yml +0 -44
  11. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/.editorconfig +0 -0
  12. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/.gitignore +0 -0
  13. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/CONTRIBUTING.md +0 -0
  14. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/DESIGN.md +0 -0
  15. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/DEVELOPMENT.md +0 -0
  16. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/LICENSE.md +0 -0
  17. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/__init__.py +0 -0
  18. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/common.py +0 -0
  19. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/cli/helper.py +0 -0
  20. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/src/git_remote_dropbox/git.py +0 -0
  21. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/tests/.gitignore +0 -0
  22. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/tests/dropbox_delete.py +0 -0
  23. {git_remote_dropbox-2.0.5 → git_remote_dropbox-2.1.0}/tests/test-lib.sh +0 -0
  24. {git_remote_dropbox-2.0.5 → 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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-remote-dropbox
3
- Version: 2.0.5
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,7 +13,7 @@ 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.6
16
+ Requires-Python: >=3.7
17
17
  Requires-Dist: dropbox<13,>=12
18
18
  Description-Content-Type: text/markdown
19
19
 
@@ -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. `python` and matching `pip`
61
+ 1. [`uv`](https://docs.astral.sh/uv/) (or other tool like `pip`)
62
62
  2. `git`
63
- 2. Install this package with `pip install git-remote-dropbox`. Use `which git-remote-dropbox` to make sure it's available via `$PATH`. If not, edit `$PATH` appropriately.
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.
@@ -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. `python` and matching `pip`
42
+ 1. [`uv`](https://docs.astral.sh/uv/) (or other tool like `pip`)
43
43
  2. `git`
44
- 2. Install this package with `pip install git-remote-dropbox`. Use `which git-remote-dropbox` to make sure it's available via `$PATH`. If not, edit `$PATH` appropriately.
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.6"
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>=1.0.0",
46
+ "mypy>=2.0.0",
44
47
  ]
45
48
 
46
49
  [tool.hatch.envs.types.scripts]
47
- check = "mypy --strict --install-types --non-interactive {args:src tests}"
50
+ check = "mypy {args:src tests}"
51
+
52
+ [tool.mypy]
53
+ strict = true
48
54
 
49
55
  [tool.ruff.lint]
50
56
  ignore = [
@@ -18,4 +18,4 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
 
21
- __version__ = "2.0.5"
21
+ __version__ = "2.1.0"
@@ -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
- constants.APP_KEY,
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
 
@@ -2,6 +2,7 @@ import os
2
2
  from typing import TextIO
3
3
 
4
4
  APP_KEY: str = "h7d8z1irmz0r7lp"
5
+ APP_FOLDER_APP_KEY: str = "w966iez5k027tcl"
5
6
  DEVNULL: TextIO = open(os.devnull, "w") # noqa: SIM115
6
7
  PROCESSES: int = 20
7
8
  MAX_RETRIES: int = 3
@@ -169,7 +169,7 @@ class Helper:
169
169
  Handle the fetch command.
170
170
  """
171
171
  while True:
172
- _, sha, value = line.split(" ")
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
- not isinstance(rep, list)
144
- or len(rep) != 2 # noqa: PLR2004
145
- or rep[0] != "refresh"
146
- or not isinstance(rep[1], str)
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
- msg = "cannot parse as RefreshToken"
149
- raise ValueError(msg)
150
- return RefreshToken(rep[1])
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=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 [RefreshToken, LongLivedToken]:
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 = 2
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
- # try to migrate if necessary
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
- # version is correct, parse
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