-
-
Notifications
You must be signed in to change notification settings - Fork 477
Use git config values as default author and email #2271
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e7658f2
Use git config values as default
NMertsch 82ac7ec
Add towncrier fragment
NMertsch 7cb3482
Handle missing git integration setup
NMertsch f9cf7c3
Test: Align naming and docstring
NMertsch 647e975
Fix and test ConvertCommand changes
NMertsch 74f2a5b
Fix and test NewCommand changes
NMertsch c5ac324
Improve wording of towncrier announcement
NMertsch f53dc95
Change 'the git configuration' to `your git configuration`
NMertsch 352990b
Add test for get_git_config_value()
NMertsch bdd8755
Fix: Add explicit encoding
NMertsch 84203ff
Combine tests, use capsys instead of mock
NMertsch 0b387c6
Assume git is available at runtime
NMertsch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| When creating a new project with ``briefcase new``, or converting an existing project with ``briefcase convert``, Briefcase will now try to infer the author's name and email address from the git configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import itertools | ||
| from unittest import mock | ||
| from unittest.mock import MagicMock | ||
|
|
||
|
|
||
| def test_all_config_files_are_read(base_command, mock_git): | ||
| """All git config files are read (system, global, user, repo).""" | ||
| base_command.tools.git = mock_git | ||
| mock_git.config.get_config_path.side_effect = ["file1", "file2", "file3"] | ||
|
|
||
| base_command.get_git_config_value("test-section", "test-option") | ||
|
|
||
| assert mock_git.config.get_config_path.call_args_list == [ | ||
| mock.call("system"), | ||
| mock.call("global"), | ||
| mock.call("user"), | ||
| ] | ||
| expected_config_files = ["file1", "file2", "file3", ".git/config"] | ||
| mock_git.config.GitConfigParser.assert_called_once_with(expected_config_files) | ||
|
|
||
|
|
||
| def test_config_values_are_parsed(base_command, tmp_path, monkeypatch): | ||
| """If the requested value exists in one of the config files, it shall be returned.""" | ||
| import git | ||
|
|
||
| # use 'real' gitpython library (no mock) | ||
| base_command.tools.git = git | ||
|
|
||
| # mock `git.config.get_config_path` to always provide the same three local files | ||
| mock_config_paths = ["missing-file-1", "config-1", "missing-file-2"] | ||
| git.config.get_config_path = MagicMock() | ||
| git.config.get_config_path.side_effect = itertools.cycle(mock_config_paths) | ||
|
|
||
| # create local two config files | ||
| monkeypatch.chdir(tmp_path) | ||
| (tmp_path / "config-1").write_text("[user]\n\tname = Some User\n", encoding="utf-8") | ||
| (tmp_path / ".git").mkdir() | ||
| (tmp_path / ".git" / "config").write_text( | ||
| "[user]\n\temail = my@email.com\n", encoding="utf-8" | ||
| ) | ||
|
|
||
| # expect values are parsed from all existing config files | ||
| assert base_command.get_git_config_value("user", "name") == "Some User" | ||
| assert base_command.get_git_config_value("user", "email") == "my@email.com" | ||
|
|
||
| # expect that missing sections and options are handled | ||
| assert base_command.get_git_config_value("user", "something") is None | ||
| assert base_command.get_git_config_value("something", "something") is None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.