Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 987
Add trailer property#1350
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Add trailer property #1350
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| ddt>=1.1.1 | ||
| ddt>=1.1.1, !=1.4.3 | ||
| mypy | ||
| flake8 | ||
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 |
|---|---|---|
| @@ -4,6 +4,7 @@ | ||
| # | ||
| # This module is part of GitPython and is released under | ||
| # the BSD License: http://www.opensource.org/licenses/bsd-license.php | ||
| import copy | ||
| from datetime import datetime | ||
| from io import BytesIO | ||
| import re | ||
| @@ -429,3 +430,48 @@ def test_datetimes(self): | ||
| datetime(2009, 10, 8, 20, 22, 51, tzinfo=tzoffset(-7200))) | ||
| self.assertEqual(commit.committed_datetime, | ||
| datetime(2009, 10, 8, 18, 22, 51, tzinfo=utc), commit.committed_datetime) | ||
| def test_trailers(self): | ||
| KEY_1 = "Hello" | ||
| VALUE_1 = "World" | ||
| KEY_2 = "Key" | ||
| VALUE_2 = "Value with inner spaces" | ||
| # Check if KEY 1 & 2 with Value 1 & 2 is extracted from multiple msg variations | ||
| msgs = [] | ||
| msgs.append(f"Subject\n\n{KEY_1}: {VALUE_1}\n{KEY_2}: {VALUE_2}\n") | ||
| msgs.append(f"Subject\n \nSome body of a function\n \n{KEY_1}: {VALUE_1}\n{KEY_2}: {VALUE_2}\n") | ||
| msgs.append(f"Subject\n \nSome body of a function\n\nnon-key: non-value\n\n{KEY_1}: {VALUE_1}\n{KEY_2}: {VALUE_2}\n") | ||
| msgs.append(f"Subject\n \nSome multiline\n body of a function\n\nnon-key: non-value\n\n{KEY_1}: {VALUE_1}\n{KEY_2} : {VALUE_2}\n") | ||
| for msg in msgs: | ||
| commit = self.rorepo.commit('master') | ||
| commit = copy.copy(commit) | ||
| commit.message = msg | ||
| assert KEY_1 in commit.trailers.keys() | ||
| assert KEY_2 in commit.trailers.keys() | ||
| assert commit.trailers[KEY_1] == VALUE_1 | ||
| assert commit.trailers[KEY_2] == VALUE_2 | ||
| # Check that trailer stays empty for multiple msg combinations | ||
| msgs = [] | ||
| msgs.append(f"Subject\n") | ||
| msgs.append(f"Subject\n\nBody with some\nText\n") | ||
| msgs.append(f"Subject\n\nBody with\nText\n\nContinuation but\n doesn't contain colon\n") | ||
| msgs.append(f"Subject\n\nBody with\nText\n\nContinuation but\n only contains one :\n") | ||
| msgs.append(f"Subject\n\nBody with\nText\n\nKey: Value\nLine without colon\n") | ||
| msgs.append(f"Subject\n\nBody with\nText\n\nLine without colon\nKey: Value\n") | ||
Byron marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| for msg in msgs: | ||
| commit = self.rorepo.commit('master') | ||
| commit = copy.copy(commit) | ||
| commit.message = msg | ||
| assert len(commit.trailers.keys()) == 0 | ||
| # check that only the last key value paragraph is evaluated | ||
| commit = self.rorepo.commit('master') | ||
| commit = copy.copy(commit) | ||
| commit.message = f"Subject\n\nMultiline\nBody\n\n{KEY_1}: {VALUE_1}\n\n{KEY_2}: {VALUE_2}\n" | ||
| assert KEY_1 not in commit.trailers.keys() | ||
| assert KEY_2 in commit.trailers.keys() | ||
| assert commit.trailers[KEY_2] == VALUE_2 | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can someone help with this?
I don't know how to get mypy to accept
subprocess.PIPEas argumentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe @Yobmod could help here.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the istream type annotation is too narrow in cmd.Git.execute().
It should be
int | IO | Noneif we accept any args that Popen does.But execute() needs a lot more annotations anyway to clear up the remaining str | bytes problems from py2 and all the overloapping arg type
@overloads.So you can update the type annotation, or leave the
type: ignorefor now.Once annotations updated, mypy should then warn that the type: ignore is no longer needed.