Skip to content

Commit e7883a4

Browse files
authored
Merge pull request #11 from somasis/master
Add a ${username} variable for use in targets
2 parents f84376d + 4ea7262 commit e7883a4

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

passgithelper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ def skip(line, skip):
354354
# TODO handle exceptions
355355
pass_target = mapping.get(section, 'target').replace(
356356
"${host}", request['host'])
357+
if 'username' in request:
358+
pass_target = pass_target.replace(
359+
"${username}", request['username'])
357360

358361
password_extractor = SpecificLineExtractor(
359362
0, 0, option_suffix='_password')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[*]
2-
target=dev/${host}
2+
target=dev/${host}/${username}

test_passgithelper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def test_wildcard_matching(self, xdg_dir, monkeypatch, mocker, capsys):
208208
monkeypatch.setattr('sys.stdin', io.StringIO('''
209209
protocol=https
210210
host=wildcard.com
211+
username=wildcard
211212
path=subpath/bar.git'''))
212213

213214
subprocess_mock = mocker.patch('subprocess.check_output')
@@ -217,7 +218,7 @@ def test_wildcard_matching(self, xdg_dir, monkeypatch, mocker, capsys):
217218

218219
subprocess_mock.assert_called_once()
219220
subprocess_mock.assert_called_with(
220-
['pass', 'show', 'dev/wildcard.com'])
221+
['pass', 'show', 'dev/wildcard.com/wildcard'])
221222

222223
out, _ = capsys.readouterr()
223224
assert out == 'password=narf-wildcard\n'

0 commit comments

Comments
 (0)