Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix GitConfigParser not removing quotes from values#2035

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
2 changes: 2 additions & 0 deletionsgit/config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -508,6 +508,8 @@ def string_decode(v: str) -> str:
if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
is_multi_line = True
optval = string_decode(optval[1:])
elif len(optval) > 1 and optval[0] == '"' and optval[-1] == '"':
optval = optval[1:-1].strip()
# END handle multi-line
# Preserves multiple values for duplicate optnames.
cursect.add(optname, optval)
Expand Down
3 changes: 3 additions & 0 deletionstest/fixtures/git_config_with_quotes
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
[user]
name = "Cody Veal"
email = "cveal05@gmail.com"
8 changes: 7 additions & 1 deletiontest/test_config.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -391,7 +391,7 @@ def test_complex_aliases(self):
with GitConfigParser(file_obj, read_only=False) as w_config:
self.assertEqual(
w_config.get("alias", "rbi"),
'"!g() { git rebase -i origin/${1:-master} ; } ; g"',
"!g() { git rebase -i origin/${1:-master} ; } ; g",
)
self.assertEqual(
file_obj.getvalue(),
Expand All@@ -406,6 +406,12 @@ def test_empty_config_value(self):
with self.assertRaises(cp.NoOptionError):
cr.get_value("color", "ui")

def test_config_with_quotes(self):
cr = GitConfigParser(fixture_path("git_config_with_quotes"), read_only=True)

self.assertEqual(cr.get("user", "name"), "Cody Veal")
self.assertEqual(cr.get("user", "email"), "cveal05@gmail.com")

def test_get_values_works_without_requiring_any_other_calls_first(self):
file_obj = self._to_memcache(fixture_path("git_config_multiple"))
cr = GitConfigParser(file_obj, read_only=True)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp