fastgit 0.1.4__tar.gz → 0.1.6__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.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastgit
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Use git from python, fast
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
- License: Apache-2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: Repository, https://github.com/AnswerDotAI/fastgit
8
8
  Project-URL: Documentation, https://AnswerDotAI.github.io/fastgit
9
9
  Keywords: nbdev,jupyter,notebook,python
@@ -12,7 +12,7 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Requires-Python: >=3.9
15
+ Requires-Python: >=3.11
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: fastcore>=1.12.27
@@ -39,7 +39,7 @@ $ pip install fastgit
39
39
 
40
40
  ### How to use
41
41
 
42
- Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Results have leading and trailing whitespace stripped:
42
+ Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Trailing newlines are stripped from results:
43
43
 
44
44
  ``` python
45
45
  import shutil, tempfile
@@ -19,7 +19,7 @@ $ pip install fastgit
19
19
 
20
20
  ### How to use
21
21
 
22
- Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Results have leading and trailing whitespace stripped:
22
+ Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Trailing newlines are stripped from results:
23
23
 
24
24
  ``` python
25
25
  import shutil, tempfile
@@ -4,6 +4,6 @@
4
4
 
5
5
  Commands run through the installed `git` executable and return its text output. There is no separate object model for repositories and commits. Both synchronous and asynchronous clients are available."""
6
6
 
7
- __version__ = "0.1.4"
7
+ __version__ = "0.1.6"
8
8
 
9
9
  from .core import *
@@ -1,31 +1,32 @@
1
1
  # Autogenerated by nbdev
2
2
 
3
- d = { 'settings': { 'branch': 'main',
4
- 'doc_baseurl': '/fastgit',
5
- 'doc_host': 'https://AnswerDotAI.github.io',
6
- 'git_url': 'https://github.com/AnswerDotAI/fastgit',
7
- 'lib_path': 'fastgit'},
8
- 'syms': { 'fastgit.core': { 'fastgit.core.Git': ('core.html#git', 'fastgit/core.py'),
9
- 'fastgit.core.Git.__call__': ('core.html#git.__call__', 'fastgit/core.py'),
10
- 'fastgit.core.Git.__getattr__': ('core.html#git.__getattr__', 'fastgit/core.py'),
3
+ d = { 'syms': { 'fastgit.core': { 'fastgit.core.GitRes': ('core.html#gitres', 'fastgit/core.py'),
4
+ 'fastgit.core.GitRes.__new__': ('core.html#gitres.__new__', 'fastgit/core.py'),
5
+ 'fastgit.core.GitRes.__repr__': ('core.html#gitres.__repr__', 'fastgit/core.py'),
6
+ 'fastgit.core._gitcmd': ('core.html#_gitcmd', 'fastgit/core.py'),
7
+ 'fastgit.core._depr_uname': ('core.html#_depr_uname', 'fastgit/core.py'),
8
+ 'fastgit.core._gitres': ('core.html#_gitres', 'fastgit/core.py'),
9
+ 'fastgit.core._runlocal': ('core.html#_runlocal', 'fastgit/core.py'),
10
+ 'fastgit.core.callgit': ('core.html#callgit', 'fastgit/core.py'),
11
+ 'fastgit.core.get_top': ('core.html#get_top', 'fastgit/core.py'),
12
+ 'fastgit.core._longopts': ('core.html#_longopts', 'fastgit/core.py'),
13
+ 'fastgit.core.Git': ('core.html#git', 'fastgit/core.py'),
11
14
  'fastgit.core.Git.__init__': ('core.html#git.__init__', 'fastgit/core.py'),
15
+ 'fastgit.core.Git.__call__': ('core.html#git.__call__', 'fastgit/core.py'),
16
+ 'fastgit.core.Git._run': ('core.html#git._run', 'fastgit/core.py'),
12
17
  'fastgit.core.Git._arun': ('core.html#git._arun', 'fastgit/core.py'),
13
18
  'fastgit.core.Git._err': ('core.html#git._err', 'fastgit/core.py'),
14
- 'fastgit.core.Git._run': ('core.html#git._run', 'fastgit/core.py'),
15
- 'fastgit.core.Git.commits': ('core.html#git.commits', 'fastgit/core.py'),
16
- 'fastgit.core.Git.current_branch': ('core.html#git.current_branch', 'fastgit/core.py'),
19
+ 'fastgit.core.Git.__getattr__': ('core.html#git.__getattr__', 'fastgit/core.py'),
20
+ 'fastgit.core.Git.top': ('core.html#git.top', 'fastgit/core.py'),
17
21
  'fastgit.core.Git.exists': ('core.html#git.exists', 'fastgit/core.py'),
18
22
  'fastgit.core.Git.head_sha': ('core.html#git.head_sha', 'fastgit/core.py'),
19
23
  'fastgit.core.Git.last_commit': ('core.html#git.last_commit', 'fastgit/core.py'),
20
- 'fastgit.core.Git.top': ('core.html#git.top', 'fastgit/core.py'),
21
- 'fastgit.core.GitRes': ('core.html#gitres', 'fastgit/core.py'),
22
- 'fastgit.core.GitRes.__new__': ('core.html#gitres.__new__', 'fastgit/core.py'),
24
+ 'fastgit.core.Git.commits': ('core.html#git.commits', 'fastgit/core.py'),
25
+ 'fastgit.core.Git.current_branch': ('core.html#git.current_branch', 'fastgit/core.py'),
23
26
  'fastgit.core._arunlocal': ('core.html#_arunlocal', 'fastgit/core.py'),
24
- 'fastgit.core._depr_uname': ('core.html#_depr_uname', 'fastgit/core.py'),
25
- 'fastgit.core._gitcmd': ('core.html#_gitcmd', 'fastgit/core.py'),
26
- 'fastgit.core._gitres': ('core.html#_gitres', 'fastgit/core.py'),
27
- 'fastgit.core._longopts': ('core.html#_longopts', 'fastgit/core.py'),
28
- 'fastgit.core._runlocal': ('core.html#_runlocal', 'fastgit/core.py'),
29
- 'fastgit.core.acallgit': ('core.html#acallgit', 'fastgit/core.py'),
30
- 'fastgit.core.callgit': ('core.html#callgit', 'fastgit/core.py'),
31
- 'fastgit.core.get_top': ('core.html#get_top', 'fastgit/core.py')}}}
27
+ 'fastgit.core.acallgit': ('core.html#acallgit', 'fastgit/core.py')}},
28
+ 'settings': { 'branch': 'main',
29
+ 'git_url': 'https://github.com/AnswerDotAI/fastgit',
30
+ 'doc_host': 'https://AnswerDotAI.github.io',
31
+ 'doc_baseurl': '/fastgit',
32
+ 'lib_path': 'fastgit'}}
@@ -18,12 +18,14 @@ from functools import cache
18
18
  _ok1 = {'merge-tree','merge-base','grep','check-ignore','diff','diff-index','diff-files','diff-tree','show-ref','config','rev-parse'}
19
19
 
20
20
  class GitRes(str):
21
- "Git output `str`, carrying the command's `returncode`"
22
- def __new__(cls, s, returncode=0):
23
- self = super().__new__(cls, s)
24
- self.returncode = returncode
21
+ "Git output text for display, with raw `stdout`, `stderr` and `returncode`"
22
+ def __new__(cls, stdout, stderr, returncode=0):
23
+ self = super().__new__(cls, (stdout + stderr).rstrip('\r\n'))
24
+ self.stdout,self.stderr,self.returncode = stdout,stderr,returncode
25
25
  return self
26
26
 
27
+ def __repr__(self): return str(self)
28
+
27
29
  # %% ../nbs/00_core.ipynb #e4c0a290
28
30
  def _gitcmd(path, *args, pre=None):
29
31
  cmd = ['git', '-C', str(Path(path).expanduser().resolve())] + list(args)
@@ -38,7 +40,7 @@ def _depr_uname(uname, pre):
38
40
  def _gitres(args, out, err, returncode, ok_exit):
39
41
  if ok_exit is None: ok_exit = 1 if args and args[0] in _ok1 else 0
40
42
  if returncode not in (0, *listify(ok_exit)): raise CalledProcessError(returncode, ['git', *args], out, err)
41
- return GitRes((out + err).strip(), returncode)
43
+ return GitRes(out, err, returncode)
42
44
 
43
45
  def _runlocal(path, args, pre=None):
44
46
  "Default runner: compose the local argv and run it in a subprocess"
@@ -53,7 +55,7 @@ def callgit(
53
55
  ok_exit=None, # Extra accepted exit codes (default: 1 for `_ok1` commands)
54
56
  runner=None, # Replaces the local subprocess: `(path, args, pre) -> (stdout, stderr, returncode)`
55
57
  ):
56
- "Run git in `path`, returning stripped stdout+stderr as a `GitRes`"
58
+ "Run git in `path`; its `GitRes` strips trailing newlines for display and retains raw stdout/stderr"
57
59
  out,err,rc = (runner or _runlocal)(path, list(args), pre=_depr_uname(uname, pre))
58
60
  return _gitres(args, out, err, rc, ok_exit)
59
61
 
@@ -83,7 +85,7 @@ class Git:
83
85
  ok_exit=None, # Extra accepted exit codes (default: 1 for commands like `diff` where it isn't an error)
84
86
  **kwargs # Become flags: short keys as `-k v`, long as `--key=v` (`_` to `-`; `True` bare, `False` dropped); `__` passes paths after `--`
85
87
  ):
86
- "Run `git cmd` in `self.d`, returning a `GitRes` (or an awaitable of one when `sync=False`)"
88
+ "Run `git cmd` in `self.d`, returning a `GitRes`, or `None` if it fails without `raise_exc` (an awaitable of either when `sync=False`)"
87
89
  paths = [str(p) for p in listify(kwargs.pop('__', None) or [])]
88
90
  args = listify(args)
89
91
  kwargs = {k:v for k,v in kwargs.items() if v is not False}
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastgit
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Use git from python, fast
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
- License: Apache-2.0
6
+ License-Expression: Apache-2.0
7
7
  Project-URL: Repository, https://github.com/AnswerDotAI/fastgit
8
8
  Project-URL: Documentation, https://AnswerDotAI.github.io/fastgit
9
9
  Keywords: nbdev,jupyter,notebook,python
@@ -12,7 +12,7 @@ Classifier: Intended Audience :: Developers
12
12
  Classifier: Development Status :: 3 - Alpha
13
13
  Classifier: Programming Language :: Python :: 3
14
14
  Classifier: Programming Language :: Python :: 3 :: Only
15
- Requires-Python: >=3.9
15
+ Requires-Python: >=3.11
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
18
  Requires-Dist: fastcore>=1.12.27
@@ -39,7 +39,7 @@ $ pip install fastgit
39
39
 
40
40
  ### How to use
41
41
 
42
- Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Results have leading and trailing whitespace stripped:
42
+ Create a [`Git`](https://AnswerDotAI.github.io/fastgit/core.html#git) object for the directory you want to work in. Every command runs in that directory. The default local runner expands `~` and resolves relative paths. A custom `runner` receives the supplied directory unchanged. Trailing newlines are stripped from results:
43
43
 
44
44
  ``` python
45
45
  import shutil, tempfile
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["setuptools>=64"]
2
+ requires = ["setuptools>=77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
@@ -7,8 +7,8 @@ name = "fastgit"
7
7
  dynamic = ["version"]
8
8
  description = "Use git from python, fast"
9
9
  readme = "README.md"
10
- requires-python = ">=3.9"
11
- license = {text = "Apache-2.0"}
10
+ requires-python = ">=3.11"
11
+ license = "Apache-2.0"
12
12
  authors = [{name = "Jeremy Howard", email = "github@jhoward.fastmail.fm"}]
13
13
  keywords = ['nbdev', 'jupyter', 'notebook', 'python']
14
14
  classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 3 - Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
@@ -28,6 +28,7 @@ version = {attr = "fastgit.__version__"}
28
28
  include = ["fastgit"]
29
29
 
30
30
  [tool.nbdev]
31
+ to_meta = ["export"]
31
32
  allowed_metadata_keys = ['solveit']
32
33
  allowed_cell_metadata_keys = ['solveit_ai']
33
34
  custom_sidebar = false
File without changes
File without changes