Skip to content

Commit 2e13f57

Browse files
committed
If the maintainer-name parameter is not set, try to use the git global user.name (likely a full name) before trying to use the OS login name
Signed-off-by: Larry Gezelius <[email protected]>
1 parent bca9587 commit 2e13f57

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

ros2pkg/ros2pkg/verb/create.py

+19-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def add_arguments(self, parser, cli_name):
7979
'--maintainer-email',
8080
help='email address of the maintainer of this package'),
8181
parser.add_argument(
82-
'--maintainer-name', default=getpass.getuser(),
82+
'--maintainer-name',
8383
help='name of the maintainer of this package'),
8484
parser.add_argument(
8585
'--node-name',
@@ -97,13 +97,29 @@ def main(self, *, args):
9797
print('Supported licenses:\n%s' % ('\n'.join(available_licenses)))
9898
sys.exit(0)
9999

100-
maintainer = Person(args.maintainer_name)
100+
git = shutil.which('git')
101+
102+
if args.maintainer_name:
103+
maintainer_name = args.maintainer_name
104+
else:
105+
# try getting the name from the global git config
106+
if git is not None:
107+
p = subprocess.Popen(
108+
[git, 'config', 'user.name'],
109+
stdout=subprocess.PIPE)
110+
resp = p.communicate()
111+
name = resp[0].decode().rstrip()
112+
if name:
113+
maintainer_name = name
114+
if not maintainer_name:
115+
maintainer_name = getpass.getuser()
116+
117+
maintainer = Person(maintainer_name)
101118

102119
if args.maintainer_email:
103120
maintainer.email = args.maintainer_email
104121
else:
105122
# try getting the email from the global git config
106-
git = shutil.which('git')
107123
if git is not None:
108124
p = subprocess.Popen(
109125
[git, 'config', 'user.email'],

0 commit comments

Comments
 (0)