fastgit 0.0.5__tar.gz → 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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastgit
3
- Version: 0.0.5
3
+ Version: 0.1.0
4
4
  Summary: Use git from python, fast
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
6
  License: Apache-2.0
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
15
15
  Requires-Python: >=3.9
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
+ Requires-Dist: fastcore>=1.12.27
18
19
  Dynamic: license-file
19
20
 
20
21
  # fastgit
@@ -34,8 +35,7 @@ $ pip install fastgit
34
35
 
35
36
  ### How to use
36
37
 
37
- In this example we run `git init` on a directory, add a *.gitignore*,
38
- and commit it.
38
+ In this example we run `git init` on a directory, add a *.gitignore*, and commit it.
39
39
 
40
40
  ``` python
41
41
  import shutil, tempfile
@@ -15,8 +15,7 @@ $ pip install fastgit
15
15
 
16
16
  ### How to use
17
17
 
18
- In this example we run `git init` on a directory, add a *.gitignore*,
19
- and commit it.
18
+ In this example we run `git init` on a directory, add a *.gitignore*, and commit it.
20
19
 
21
20
  ``` python
22
21
  import shutil, tempfile
@@ -0,0 +1,3 @@
1
+ __version__ = "0.1.0"
2
+
3
+ from .core import *
@@ -9,6 +9,8 @@ d = { 'settings': { 'branch': 'main',
9
9
  'fastgit.core.Git.__call__': ('core.html#git.__call__', 'fastgit/core.py'),
10
10
  'fastgit.core.Git.__getattr__': ('core.html#git.__getattr__', 'fastgit/core.py'),
11
11
  'fastgit.core.Git.__init__': ('core.html#git.__init__', 'fastgit/core.py'),
12
+ 'fastgit.core.Git.commits': ('core.html#git.commits', 'fastgit/core.py'),
13
+ 'fastgit.core.Git.current_branch': ('core.html#git.current_branch', 'fastgit/core.py'),
12
14
  'fastgit.core.Git.exists': ('core.html#git.exists', 'fastgit/core.py'),
13
15
  'fastgit.core.Git.head_sha': ('core.html#git.head_sha', 'fastgit/core.py'),
14
16
  'fastgit.core.Git.last_commit': ('core.html#git.last_commit', 'fastgit/core.py'),
@@ -1,6 +1,6 @@
1
1
  """Implementation of fastgit
2
2
 
3
- Docs: https://AnswerDotAI.github.io/fastgitcore.html.md"""
3
+ Docs: https://AnswerDotAI.github.io/fastgit/core.html.md"""
4
4
 
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_core.ipynb.
6
6
 
@@ -11,16 +11,19 @@ __all__ = ['callgit', 'get_top', 'Git']
11
11
  from fastcore.utils import *
12
12
  import subprocess
13
13
  from subprocess import CalledProcessError
14
- import shutil,stat
15
14
 
16
15
  # %% ../nbs/00_core.ipynb #e4c0a290
17
- def callgit(path, *args, split=None, uname=None):
16
+ def callgit(path, *args, uname=None, pre=None):
17
+ "Run git in `path`, returning stripped stdout+stderr as a single `str`"
18
+ assert not (uname and pre), "Pass `uname` or `pre`, not both"
19
+ if uname:
20
+ warn("`uname` is deprecated; pass e.g `pre=['/usr/bin/sudo','-u',uname]` instead", DeprecationWarning, stacklevel=2)
21
+ pre = ['/usr/bin/sudo', '-u', uname]
18
22
  fp = Path(path).expanduser().resolve()
19
23
  args = ['git', '-C', str(fp)] + list(args)
20
- if uname: args = ['/usr/bin/sudo', '-u', uname] + args
21
- res = subprocess.run(args, capture_output=True, text=True, check=True).stdout.strip()
22
- if split is None: return res.splitlines() if '\n' in res else res
23
- return res.splitlines() if split else res
24
+ if pre: args = [*pre, *args]
25
+ r = subprocess.run(args, capture_output=True, text=True, check=True)
26
+ return (r.stdout + r.stderr).strip()
24
27
 
25
28
  # %% ../nbs/00_core.ipynb #4c0df6c6
26
29
  def get_top(folder):
@@ -29,31 +32,42 @@ def get_top(folder):
29
32
 
30
33
  # %% ../nbs/00_core.ipynb #97f78839
31
34
  class Git:
32
- def __init__(self, d): self.d = Path(d).expanduser()
35
+ "Run git commands in dir `d`"
36
+ def __init__(self, d, pre=None, raise_exc=False): self.d,self.pre,self.raise_exc = Path(d).expanduser(),pre,raise_exc
33
37
 
34
- def __call__(self, cmd, *args, split=None, mute_errors=False, **kwargs):
38
+ def __call__(self, cmd, *args, mute_errors=False, raise_exc=None, **kwargs):
35
39
  paths = [str(p) for p in listify(kwargs.pop('__', None) or [])]
36
40
  args = listify(args)
37
- args += concat((f'-{k}',v) for k,v in kwargs.items() if len(k)==1 and v is not True)
41
+ kwargs = {k:v for k,v in kwargs.items() if v is not False}
42
+ args += concat((f'-{k}',str(v)) for k,v in kwargs.items() if len(k)==1 and v is not True)
38
43
  args += [f'-{k}' for k,v in kwargs.items() if len(k)==1 and v is True]
39
- args += [f'--{k.replace("_","-")}={v}' for k,v in kwargs.items() if len(k)>1 and v is not True and v is not False]
44
+ args += [f'--{k.replace("_","-")}={v}' for k,v in kwargs.items() if len(k)>1 and v is not True]
40
45
  args += [f'--{k.replace("_","-")}' for k,v in kwargs.items() if len(k)>1 and v is True]
41
46
  if paths: args += ['--'] + paths
42
- try: return callgit(self.d, cmd, *args, split=split)
47
+ try: return callgit(self.d, cmd, *args, pre=self.pre)
43
48
  except CalledProcessError as e:
49
+ if ifnone(raise_exc, self.raise_exc): raise
44
50
  if not mute_errors: print(f'ERROR: Git.__call__ caught exception {e} \n with stderr={e.stderr}')
45
51
 
46
52
  def __getattr__(self, nm):
47
53
  if nm.startswith('_'): raise AttributeError(nm)
48
54
  return partial(self, nm.replace('_','-'))
49
55
 
50
- def top(self): return self.rev_parse('--show-toplevel', mute_errors=True)
51
-
56
+ def top(self): return self.rev_parse('--show-toplevel', mute_errors=True, raise_exc=False)
57
+
52
58
  @property
53
59
  def exists(self): return self.top() is not None
54
60
  @property
55
- def head_sha(self): return self.rev_parse('HEAD', mute_errors=True)
61
+ def head_sha(self): return self.rev_parse('HEAD', mute_errors=True, raise_exc=False)
56
62
 
57
63
  # %% ../nbs/00_core.ipynb #b688e74b
58
64
  @patch(as_prop=True)
59
65
  def last_commit(self:Git): return self.log('-1', pretty='format:%s')
66
+
67
+ # %% ../nbs/00_core.ipynb #fdf315b8
68
+ @patch(as_prop=True)
69
+ def commits(self:Git): return (self.log('--oneline', mute_errors=True, raise_exc=False) or '').splitlines()
70
+
71
+ # %% ../nbs/00_core.ipynb #712ca55b
72
+ @patch(as_prop=True)
73
+ def current_branch(self:Git): return self.branch('--show-current')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fastgit
3
- Version: 0.0.5
3
+ Version: 0.1.0
4
4
  Summary: Use git from python, fast
5
5
  Author-email: Jeremy Howard <github@jhoward.fastmail.fm>
6
6
  License: Apache-2.0
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
15
15
  Requires-Python: >=3.9
16
16
  Description-Content-Type: text/markdown
17
17
  License-File: LICENSE
18
+ Requires-Dist: fastcore>=1.12.27
18
19
  Dynamic: license-file
19
20
 
20
21
  # fastgit
@@ -34,8 +35,7 @@ $ pip install fastgit
34
35
 
35
36
  ### How to use
36
37
 
37
- In this example we run `git init` on a directory, add a *.gitignore*,
38
- and commit it.
38
+ In this example we run `git init` on a directory, add a *.gitignore*, and commit it.
39
39
 
40
40
  ``` python
41
41
  import shutil, tempfile
@@ -9,4 +9,5 @@ fastgit.egg-info/PKG-INFO
9
9
  fastgit.egg-info/SOURCES.txt
10
10
  fastgit.egg-info/dependency_links.txt
11
11
  fastgit.egg-info/entry_points.txt
12
+ fastgit.egg-info/requires.txt
12
13
  fastgit.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ fastcore>=1.12.27
@@ -12,7 +12,7 @@ license = {text = "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"]
15
- dependencies = []
15
+ dependencies = ['fastcore>=1.12.27']
16
16
 
17
17
  [project.urls]
18
18
  Repository = "https://github.com/AnswerDotAI/fastgit"
@@ -31,3 +31,6 @@ include = ["fastgit"]
31
31
  allowed_metadata_keys = ['solveit']
32
32
  allowed_cell_metadata_keys = ['solveit_ai']
33
33
  custom_sidebar = false
34
+
35
+ [tool.chkstyle]
36
+ skip_paths = ["_modidx.py"]
@@ -1,3 +0,0 @@
1
- __version__ = "0.0.5"
2
-
3
- from .core import *
File without changes
File without changes
File without changes