git-project 0.0.30__tar.gz → 0.0.32__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 (45) hide show
  1. git_project-0.0.32/.git +1 -0
  2. {git_project-0.0.30 → git_project-0.0.32}/PKG-INFO +1 -1
  3. {git_project-0.0.30 → git_project-0.0.32}/_version.py +2 -2
  4. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/git.py +27 -7
  5. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/substitutable.py +3 -1
  6. {git_project-0.0.30 → git_project-0.0.32}/tests/test_substitutable.py +45 -0
  7. git_project-0.0.30/.git +0 -1
  8. git_project-0.0.30/test.out +0 -131
  9. {git_project-0.0.30 → git_project-0.0.32}/.gitignore +0 -0
  10. {git_project-0.0.30 → git_project-0.0.32}/CONTRIBUTORS +0 -0
  11. {git_project-0.0.30 → git_project-0.0.32}/COPYING +0 -0
  12. {git_project-0.0.30 → git_project-0.0.32}/MANIFEST.in +0 -0
  13. {git_project-0.0.30 → git_project-0.0.32}/docs/Makefile +0 -0
  14. {git_project-0.0.30 → git_project-0.0.32}/docs/authors.rst +0 -0
  15. {git_project-0.0.30 → git_project-0.0.32}/docs/changelog.rst +0 -0
  16. {git_project-0.0.30 → git_project-0.0.32}/docs/conf.py +0 -0
  17. {git_project-0.0.30 → git_project-0.0.32}/docs/index.rst +0 -0
  18. {git_project-0.0.30 → git_project-0.0.32}/docs/intro.rst +0 -0
  19. {git_project-0.0.30 → git_project-0.0.32}/docs/license.rst +0 -0
  20. {git_project-0.0.30 → git_project-0.0.32}/docs/make.bat +0 -0
  21. {git_project-0.0.30 → git_project-0.0.32}/pyproject.toml +0 -0
  22. {git_project-0.0.30 → git_project-0.0.32}/requirements.txt +0 -0
  23. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/__init__.py +0 -0
  24. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/commandline.py +0 -0
  25. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/configobj.py +0 -0
  26. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/exception.py +0 -0
  27. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/gitproject.py +0 -0
  28. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/main.py +0 -0
  29. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/parsermanager.py +0 -0
  30. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/plugin.py +0 -0
  31. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/pluginmanager.py +0 -0
  32. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/project.py +0 -0
  33. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/runnable.py +0 -0
  34. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/scopedobj.py +0 -0
  35. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/shell.py +0 -0
  36. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/test_support/__init__.py +0 -0
  37. {git_project-0.0.30 → git_project-0.0.32}/src/git_project/test_support/common.py +0 -0
  38. {git_project-0.0.30 → git_project-0.0.32}/tests/conftest.py +0 -0
  39. {git_project-0.0.30 → git_project-0.0.32}/tests/test_confobj.py +0 -0
  40. {git_project-0.0.30 → git_project-0.0.32}/tests/test_git.py +0 -0
  41. {git_project-0.0.30 → git_project-0.0.32}/tests/test_gitproject.py +0 -0
  42. {git_project-0.0.30 → git_project-0.0.32}/tests/test_main.py +0 -0
  43. {git_project-0.0.30 → git_project-0.0.32}/tests/test_project.py +0 -0
  44. {git_project-0.0.30 → git_project-0.0.32}/tests/test_runnable.py +0 -0
  45. {git_project-0.0.30 → git_project-0.0.32}/tests/test_scopedobj.py +0 -0
@@ -0,0 +1 @@
1
+ gitdir: /home/dag/src/git-project/.git/worktrees/master/
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: git-project
3
- Version: 0.0.30
3
+ Version: 0.0.32
4
4
  Summary: The extensible stupid project manager
5
5
  Author-email: "David A. Greene" <dag@obbligato.org>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '0.0.30'
21
- __version_tuple__ = version_tuple = (0, 0, 30)
20
+ __version__ = version = '0.0.32'
21
+ __version_tuple__ = version_tuple = (0, 0, 32)
@@ -48,7 +48,7 @@ class Git(object):
48
48
  implement git-project functionality."""
49
49
 
50
50
  class RemoteCallbacks(pygit2.RemoteCallbacks):
51
- def __init__(self):
51
+ def __init__(self, ssh_id: str):
52
52
  self.started_transfer = False
53
53
  self.transfer_done = False
54
54
 
@@ -57,11 +57,15 @@ class Git(object):
57
57
 
58
58
  self.null_oid = pygit2.Oid(hex='0000000000000000000000000000000000000000')
59
59
 
60
+ self.ssh_id = ssh_id
61
+
60
62
  def credentials(self, url, username_from_url, allowed_types):
61
63
  if allowed_types & pygit2.enums.CredentialType.SSH_KEY:
62
64
  return pygit2.Keypair(
63
- username_from_url, str(Path.home() / '.ssh' / 'id_rsa.pub'),
64
- str(Path.home() / '.ssh' / 'id_rsa'), ''
65
+ username_from_url,
66
+ str(Path.home() / '.ssh' / f'{self.ssh_id}.pub'),
67
+ str(Path.home() / '.ssh' / self.ssh_id),
68
+ ''
65
69
  )
66
70
  elif allowed_types & pygit2.enums.CredentialType.USERNAME:
67
71
  return pygit2.Username(username_from_url)
@@ -373,11 +377,18 @@ class Git(object):
373
377
  del self._sections[section_name]
374
378
 
375
379
  class RemoteBranchDeleteCallback(pygit2.RemoteCallbacks):
380
+ def __init__(self, ssh_id: str):
381
+ super().__init__(ssh_id)
382
+
376
383
  """Check the result of remove branch prune operations."""
377
384
  def credentials(self, url, username_from_url, allowed_types):
378
385
  if allowed_types & pygit2.enums.CredentialType.SSH_KEY:
379
- return pygit2.Keypair(username_from_url, str(Path.home() / '.ssh' / 'id_rsa.pub'),
380
- str(Path.home() / '.ssh' / 'id_rsa'), '')
386
+ return pygit2.Keypair(
387
+ username_from_url,
388
+ str(Path.home() / '.ssh' / f'{self.ssh_id}.pub'),
389
+ str(Path.home() / '.ssh' / self.ssh_id),
390
+ ''
391
+ )
381
392
  elif allowed_types & pygit2.enums.CredentialType.USERNAME:
382
393
  return pygit2.Username(username_from_url)
383
394
  return None
@@ -388,6 +399,9 @@ class Git(object):
388
399
  format(message))
389
400
 
390
401
  class LsRemotesCallbacks(pygit2.RemoteCallbacks):
402
+ def __init__(self, ssh_id: str):
403
+ super().__init__(ssh_id)
404
+
391
405
  def credentials(self, url, username_from_url, allowed_types):
392
406
  if allowed_types & pygit2.enums.CredentialType.SSH_KEY:
393
407
  return pygit2.Keypair(username_from_url, str(Path.home() / '.ssh' / 'id_rsa.pub'),
@@ -421,6 +435,10 @@ class Git(object):
421
435
  if self.has_repo():
422
436
  self._config = self.Config(self, self._repo.config)
423
437
 
438
+ def get_ssh_id(self):
439
+ """Return the ssh ID to use for this repository."""
440
+ return self.config.get_item('ssh', 'id')
441
+
424
442
  def is_bare_repository(self):
425
443
  """Return whether the configured repository is bare."""
426
444
  return self._repo.is_bare
@@ -821,7 +839,9 @@ class Git(object):
821
839
  # (local) name of the branch on the remote side. Assume for now that
822
840
  # it's the same as our local name.
823
841
  remote_refname = self.get_remote_push_refname(refname, remote)
824
- for item in self._repo.remotes[remote].ls_remotes(callbacks=Git.LsRemotesCallbacks()):
842
+ for item in self._repo.remotes[remote].ls_remotes(
843
+ callbacks=Git.LsRemotesCallbacks(self.get_ssh_id())
844
+ ):
825
845
  if not item['local'] and item['name'] == refname:
826
846
  return True
827
847
  return False
@@ -832,7 +852,7 @@ class Git(object):
832
852
  # reason push :branch_name doesn't work. push
833
853
  # :remotes/<remote>/branch_name also doesn't work.
834
854
  refname = self.branch_name_to_refname(branch_name)
835
- callback = self.RemoteBranchDeleteCallback();
855
+ callback = self.RemoteBranchDeleteCallback(self.get_ssh_id());
836
856
  refspecs = [f':{refname}']
837
857
  remote = self._repo.remotes[remote]
838
858
  remote.push(refspecs, callback)
@@ -95,7 +95,9 @@ class SubstitutableConfigObject(ConfigObject):
95
95
  current_branch = git.refname_to_branch_name(head_name.read_text().strip())
96
96
  break
97
97
 
98
- formats['branch'] = current_branch
98
+ print(f'current_branch: {current_branch}')
99
+ if current_branch is not None:
100
+ formats['branch'] = current_branch
99
101
 
100
102
  # Make sure substitutions don't reference themselves, to avoid an
101
103
  # infinite loop substituting.
@@ -50,6 +50,28 @@ class MySubstitutable(git_project.SubstitutableConfigObject):
50
50
  command='cd {builddir}/{branch} && make {target}',
51
51
  description='Test command')
52
52
 
53
+ class MyNoBranchSubstitutable(git_project.SubstitutableConfigObject):
54
+ def __init__(self,
55
+ git,
56
+ project_section,
57
+ subsection,
58
+ ident,
59
+ **kwargs):
60
+ super().__init__(git,
61
+ project_section,
62
+ subsection,
63
+ ident,
64
+ **kwargs)
65
+
66
+ @classmethod
67
+ def get(cls, git, project_section, ident):
68
+ return super().get(git,
69
+ project_section,
70
+ 'mysubstitutable',
71
+ ident,
72
+ command='cd {builddir} && make {target}',
73
+ description='Test command')
74
+
53
75
  def test_substitutable_get(reset_directory, git):
54
76
  substitutable = MySubstitutable.get(git, 'project', 'test')
55
77
 
@@ -542,3 +564,26 @@ def test_substitutable_substitute_preserve_escaped_braces(reset_directory, git):
542
564
  substitutable.command)
543
565
 
544
566
  assert command == f'cd {git.get_working_copy_root()}/{{{{}}path{{}}}}/to/build/{git.get_current_branch()} && make {project.target}'
567
+
568
+
569
+ def test_substitutable_substitute_no_branch(reset_directory, git):
570
+ class MyProject(git_project.ScopedConfigObject):
571
+ def __init__(self):
572
+ super().__init__(git,
573
+ 'project',
574
+ None,
575
+ 'myproject',
576
+ builddir='{git_workdir}/path/to/build',
577
+ target='debug')
578
+
579
+ substitutable = MyNoBranchSubstitutable.get(git, 'project', 'test')
580
+
581
+ project = MyProject()
582
+
583
+ git.detach_head()
584
+
585
+ command = substitutable.substitute_value(git,
586
+ project,
587
+ substitutable.command)
588
+
589
+ assert command == f'cd {git.get_working_copy_root()}/path/to/build && make {project.target}'
git_project-0.0.30/.git DELETED
@@ -1 +0,0 @@
1
- gitdir: /home/dag/src/git-project/.git/worktrees/dev/
@@ -1,131 +0,0 @@
1
- ============================= test session starts ==============================
2
- platform linux -- Python 3.11.9, pytest-8.2.2, pluggy-1.5.0
3
- rootdir: /home/dag/src/git-project/dev
4
- configfile: pyproject.toml
5
- plugins: anyio-4.3.0, console-scripts-1.4.1
6
- collected 106 items
7
-
8
- tests/test_confobj.py ............ [ 11%]
9
- tests/test_git.py .......................FF............................ [ 61%]
10
- tests/test_gitproject.py .. [ 63%]
11
- tests/test_main.py . [ 64%]
12
- tests/test_project.py ........... [ 74%]
13
- tests/test_runnable.py ........ [ 82%]
14
- tests/test_scopedobj.py ..... [ 86%]
15
- tests/test_substitutable.py .............. [100%]
16
-
17
- =================================== FAILURES ===================================
18
- ________________________________ test_git_clone ________________________________
19
-
20
- reset_directory = None
21
- remote_repository = pygit2.Repository('/tmp/pytest-of-dag/pytest-14/local_remote_test_git_clone.git0/')
22
- tmp_path_factory = TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7ff199ba1e50>, _basetemp=PosixPath('/tmp/pytest-of-dag/pytest-14'), _retention_count=3, _retention_policy='all')
23
-
24
- def test_git_clone(reset_directory, remote_repository, tmp_path_factory):
25
- path = tmp_path_factory.mktemp('clone-workdir')
26
-
27
- os.chdir(path)
28
-
29
- git = git_project.Git()
30
-
31
- remote_url = 'file://' + remote_repository.path
32
-
33
- > clone_path = git.clone(remote_url)
34
-
35
- /home/dag/src/git-project/dev/tests/test_git.py:441:
36
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
37
- /home/dag/src/git-project/dev/src/git_project/git.py:744: in clone
38
- self._repo = pygit2.clone_repository(url, target_path, bare, callbacks=callbacks)
39
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/__init__.py:217: in clone_repository
40
- payload.check_error(err)
41
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:93: in check_error
42
- raise self._stored_exception
43
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:424: in wrapper
44
- return f(*args)
45
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:552: in _transfer_progress_cb
46
- transfer_progress(TransferProgress(stats_ptr))
47
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
48
-
49
- self = <git_project.git.Git.RemoteCallbacks object at 0x7ff199a06950>
50
- stats = <pygit2.remotes.TransferProgress object at 0x7ff199a9f790>
51
-
52
- def transfer_progress(self, stats):
53
- if not self.started_transfer:
54
- self.started_transfer = True
55
- print(f'Receiving objects ({stats.total_objects})...')
56
- > self.progress.start(max_value=stats.total_objects)
57
- E TypeError: ProgressBar.start() got an unexpected keyword argument 'max_value'
58
-
59
- /home/dag/src/git-project/dev/src/git_project/git.py:77: TypeError
60
- ----------------------------- Captured stdout call -----------------------------
61
- Remote: Counting objects 1
62
- Remote: Counting objects 9
63
- Remote: Counting objects 14
64
- Remote: Counting objects 14
65
-
66
- Remote: Compressing objects: 0% (0/14)
67
- Remote: Compressing objects: 100% (14/14), done
68
-
69
- Receiving objects (14)...
70
- ___________________________ test_git_clone_with_path ___________________________
71
-
72
- reset_directory = None
73
- remote_repository = pygit2.Repository('/tmp/pytest-of-dag/pytest-14/local_remote_test_git_clone_with_path.git0/')
74
- tmp_path_factory = TempPathFactory(_given_basetemp=None, _trace=<pluggy._tracing.TagTracerSub object at 0x7ff199ba1e50>, _basetemp=PosixPath('/tmp/pytest-of-dag/pytest-14'), _retention_count=3, _retention_policy='all')
75
-
76
- def test_git_clone_with_path(reset_directory,
77
- remote_repository,
78
- tmp_path_factory):
79
- path = tmp_path_factory.mktemp('clone-workdir')
80
- os.chdir(path)
81
-
82
- git = git_project.Git()
83
-
84
- remote_url = 'file://' + remote_repository.path
85
-
86
- path = Path.cwd() / 'foo' / 'bar'
87
-
88
- os.makedirs(path)
89
-
90
- path = path / 'test-clone'
91
-
92
- > clone_path = git.clone(remote_url, path)
93
-
94
- /home/dag/src/git-project/dev/tests/test_git.py:482:
95
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
96
- /home/dag/src/git-project/dev/src/git_project/git.py:744: in clone
97
- self._repo = pygit2.clone_repository(url, target_path, bare, callbacks=callbacks)
98
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/__init__.py:217: in clone_repository
99
- payload.check_error(err)
100
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:93: in check_error
101
- raise self._stored_exception
102
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:424: in wrapper
103
- return f(*args)
104
- /home/dag/.virtualenvs/dev/lib/python3.11/site-packages/pygit2/callbacks.py:552: in _transfer_progress_cb
105
- transfer_progress(TransferProgress(stats_ptr))
106
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
107
-
108
- self = <git_project.git.Git.RemoteCallbacks object at 0x7ff198a8e350>
109
- stats = <pygit2.remotes.TransferProgress object at 0x7ff198a8eb10>
110
-
111
- def transfer_progress(self, stats):
112
- if not self.started_transfer:
113
- self.started_transfer = True
114
- print(f'Receiving objects ({stats.total_objects})...')
115
- > self.progress.start(max_value=stats.total_objects)
116
- E TypeError: ProgressBar.start() got an unexpected keyword argument 'max_value'
117
-
118
- /home/dag/src/git-project/dev/src/git_project/git.py:77: TypeError
119
- ----------------------------- Captured stdout call -----------------------------
120
- Remote: Counting objects 1
121
- Remote: Counting objects 14
122
- Remote: Counting objects 14
123
-
124
- Remote: Compressing objects: 0% (0/14)
125
- Remote: Compressing objects: 100% (14/14), done
126
-
127
- Receiving objects (14)...
128
- =========================== short test summary info ============================
129
- FAILED tests/test_git.py::test_git_clone - TypeError: ProgressBar.start() got...
130
- FAILED tests/test_git.py::test_git_clone_with_path - TypeError: ProgressBar.s...
131
- ======================== 2 failed, 104 passed in 2.74s =========================
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes