Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace invalid config key scriv.user_nick with scriv.userNick #131

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions changelog.d/20240608_184756_dickinsm.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. A new scriv changelog fragment.
..
.. Uncomment the header that is right (remove the leading dots).
..
.. Removed
.. .......
..
.. - A bullet item for the Removed category.
..
.. Added
.. .....
..
.. - A bullet item for the Added category.
..
.. Changed
.. .......
..
.. - A bullet item for the Changed category.
..
.. Deprecated
.. ..........
..
.. - A bullet item for the Deprecated category.
..
Fixed
.....

- Replaced the invalid GitHub config key ``scriv.user_nick`` with
``scriv.userNick``.
..
.. Security
.. ........
..
.. - A bullet item for the Security category.
..
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ User Nickname

Scriv includes your git or GitHub username in the file names of changelog
fragments you create. If you don't like the name it finds for you, you can set
a name as the ``scriv.user_nick`` git setting.
a name as the ``scriv.userNick`` git setting.


.. _git config: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration
Expand Down
2 changes: 1 addition & 1 deletion src/scriv/gitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def user_nick() -> str:
"""
Get a short name for the current user.
"""
nick = git_config("scriv.user_nick")
nick = git_config("scriv.userNick")
if nick:
return nick

Expand Down
6 changes: 6 additions & 0 deletions tests/faker.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Fake implementations of some of our external information sources."""

import re
import shlex
from typing import Callable, Dict, Iterable, List, Optional, Set, Tuple

Expand All @@ -8,6 +9,9 @@
# A function that simulates run_command.
CmdHandler = Callable[[List[str]], CmdResult]

# A regex to help with catching some (but not all) invalid Git config keys.
GIT_CONFIG_KEY = re.compile(r".*\.[a-zA-Z][a-zA-Z0-9-]*")


class FakeRunCommand:
"""
Expand Down Expand Up @@ -87,6 +91,8 @@ def run_command(self, argv: List[str]) -> CmdResult:

def set_config(self, name: str, value: str) -> None:
"""Set a fake Git configuration value."""
if GIT_CONFIG_KEY.fullmatch(name) is None:
raise ValueError(f"error: invalid key: {name}")
self.config[name] = value

def set_branch(self, branch_name: str) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_gitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


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


Expand Down