Skip to content

Commit e87843d

Browse files
RonnyPfannschmidtNed Batchelder
authored and
Ned Batchelder
committed
address #103: introduce scriv.user_nick setting
1 parent bd69079 commit e87843d

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
Added
3+
.....
4+
5+
- consider the git config ``scriv.user_nick`` for the user nick part
6+
of the fragment file - thanks to `Ronny Pfannschmidt <pull 106>`_, fixing `issue 103`_
7+
8+
9+
.. _issue 103: https://github.com/nedbat/scriv/pull/103
10+
.. _pull 106: https://github.com/nedbat/scriv/pull/106

src/scriv/gitinfo.py

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def user_nick() -> str:
1919
"""
2020
Get a short name for the current user.
2121
"""
22+
ok, out = run_command("git config --get scriv.user_nick")
23+
if ok:
24+
return out.strip()
25+
2226
ok, out = run_command("git config --get github.user")
2327
if ok:
2428
return out.strip()

tests/test_gitinfo.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
from scriv.gitinfo import current_branch_name, get_github_repos, user_nick
66

77

8+
def test_user_nick_from_scriv_user_nick(fake_git):
9+
fake_git.set_config("scriv.user_nick", "joedev")
10+
assert user_nick() == "joedev"
11+
12+
813
def test_user_nick_from_github(fake_git):
914
fake_git.set_config("github.user", "joedev")
1015
assert user_nick() == "joedev"
@@ -69,7 +74,7 @@ def test_real_get_github_repos():
6974
# we can't be sure what we get, except it should be word/word, and not end
7075
# with .git
7176
repos = get_github_repos()
72-
assert len(repos) == 1
77+
assert len(repos) >= 1
7378
repo = repos.pop()
7479
assert re.fullmatch(r"\w+/\w+", repo)
7580
assert not repo.endswith(".git")

0 commit comments

Comments
 (0)