Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/sync/modules/git/
Date: Mon, 27 Feb 2023 06:15:50
Message-Id: 1677478541.8924a8e3b3b4732b7792899141cc0ce76fee72ca.sam@gentoo
1 commit: 8924a8e3b3b4732b7792899141cc0ce76fee72ca
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 27 05:43:42 2023 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 27 06:15:41 2023 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8924a8e3
7
8 sync: git: add trivial type annotations
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11 Closes: https://github.com/gentoo/portage/pull/1000
12 Signed-off-by: Sam James <sam <AT> gentoo.org>
13
14 lib/portage/sync/modules/git/git.py | 17 +++++++++--------
15 1 file changed, 9 insertions(+), 8 deletions(-)
16
17 diff --git a/lib/portage/sync/modules/git/git.py b/lib/portage/sync/modules/git/git.py
18 index 3c2f9bdb4..9f70ea7ea 100644
19 --- a/lib/portage/sync/modules/git/git.py
20 +++ b/lib/portage/sync/modules/git/git.py
21 @@ -5,6 +5,8 @@ import logging
22 import re
23 import subprocess
24
25 +from typing import Tuple
26 +
27 import portage
28 from portage import os
29 from portage.util import writemsg_level, shlex_split
30 @@ -35,11 +37,11 @@ class GitSync(NewBase):
31 def __init__(self):
32 NewBase.__init__(self, "git", portage.const.GIT_PACKAGE_ATOM)
33
34 - def exists(self, **kwargs):
35 + def exists(self, **kwargs) -> bool:
36 """Tests whether the repo actually exists"""
37 return os.path.exists(os.path.join(self.repo.location, ".git"))
38
39 - def new(self, **kwargs):
40 + def new(self, **kwargs) -> Tuple[int, bool]:
41 """Do the initial clone of the repository"""
42 if kwargs:
43 self._kwargs(kwargs)
44 @@ -116,12 +118,11 @@ class GitSync(NewBase):
45
46 return (os.EX_OK, True)
47
48 - def _gen_ceiling_string(self, path):
49 + def _gen_ceiling_string(self, path: str) -> str:
50 """
51 Iteratively generate a colon delimited string of all of the
52 given path's parents, for use with GIT_CEILING_DIRECTORIES
53 """
54 - path = self.repo.location
55 directories = []
56
57 while True:
58 @@ -132,7 +133,7 @@ class GitSync(NewBase):
59
60 return ":".join(directories)
61
62 - def update(self):
63 + def update(self) -> Tuple[int, bool]:
64 """Update existing git repository, and ignore the syncuri. We are
65 going to trust the user and assume that the user is in the branch
66 that he/she wants updated. We'll let the user manage branches with
67 @@ -403,7 +404,7 @@ class GitSync(NewBase):
68
69 return (os.EX_OK, current_rev != previous_rev)
70
71 - def verify_head(self, revision="-1"):
72 + def verify_head(self, revision="-1") -> bool:
73 if self.repo.module_specific_options.get(
74 "sync-git-verify-commit-signature", "false"
75 ).lower() not in ("true", "yes"):
76 @@ -477,7 +478,7 @@ class GitSync(NewBase):
77 if openpgp_env is not None:
78 openpgp_env.close()
79
80 - def retrieve_head(self, **kwargs):
81 + def retrieve_head(self, **kwargs) -> Tuple[int, bool]:
82 """Get information about the head commit"""
83 if kwargs:
84 self._kwargs(kwargs)
85 @@ -498,7 +499,7 @@ class GitSync(NewBase):
86 ret = (1, False)
87 return ret
88
89 - def add_safe_directory(self):
90 + def add_safe_directory(self) -> bool:
91 # Add safe.directory to system gitconfig if not already configured.
92 # Workaround for bug #838271 and bug #838223.
93 location_escaped = re.escape(self.repo.location)