Skip to content

Commit

Permalink
address #103: introduce scriv.user_nick setting
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt authored and nedbat committed Oct 8, 2023
1 parent bd69079 commit 075b6c4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
10 changes: 10 additions & 0 deletions changelog.d/20231003_082812_ronny_user_nick_setting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Added
.....

- consider the git config ``scriv.user_nick`` for the user nick part
of the fragment file - thanks to `Ronny Pfannschmidt <pull 106>`_, fixing `issue 103`_


.. _issue 103: https://github.com/nedbat/scriv/pull/103
.. _pull 106: https://github.com/nedbat/scriv/pull/106
4 changes: 4 additions & 0 deletions src/scriv/gitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def user_nick() -> str:
"""
Get a short name for the current user.
"""
ok, out = run_command("git config --get scriv.user_nick")
if ok:
return out.strip()

ok, out = run_command("git config --get github.user")
if ok:
return out.strip()
Expand Down
14 changes: 10 additions & 4 deletions tests/test_gitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from scriv.gitinfo import current_branch_name, get_github_repos, user_nick


def test_user_nick_from_scriv_user_nick(fake_git):
fake_git.set_config("scriv.user_nick", "joedev")
assert user_nick() == "joedev"


def test_user_nick_from_github(fake_git):
fake_git.set_config("github.user", "joedev")
assert user_nick() == "joedev"
Expand Down Expand Up @@ -69,7 +74,8 @@ def test_real_get_github_repos():
# we can't be sure what we get, except it should be word/word, and not end
# with .git
repos = get_github_repos()
assert len(repos) == 1
repo = repos.pop()
assert re.fullmatch(r"\w+/\w+", repo)
assert not repo.endswith(".git")
assert len(repos) >= 1
for repo in repos:

assert re.fullmatch(r"\w+/\w+", repo)
assert not repo.endswith(".git")

0 comments on commit 075b6c4

Please sign in to comment.