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

Commit5ca0fba

Browse files
author
jcole-crowdstrike
committed
Updating regex pattern to handle unicode whitespaces.
Replacing the \s whitespace characters with normal spaces (" ") to prevent breaking on unicode whitespace characters (e.g., NBSP). Without this, if a branch name contains a unicode whitespace character that falls under \s, then the branch name will be truncated.
1 parent7fbfc77 commit5ca0fba

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

‎git/remote.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ class FetchInfo(IterableObj):
325325
ERROR,
326326
)= [1<<xforxinrange(8)]
327327

328-
_re_fetch_result=re.compile(r"^\s*(.) (\[[\w\s\.$@]+\]|[\w\.$@]+)\s+(.+) -> ([^\s]+)( \(.*\)?$)?")
328+
_re_fetch_result=re.compile(r"^*(.) (\[[\w \.$@]+\]|[\w\.$@]+)+(.+) -> ([^]+)( \(.*\)?$)?")
329329

330330
_flag_map:Dict[flagKeyLiteral,int]= {
331331
"!":ERROR,

‎test/test_remote.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,21 @@ def test_push_unsafe_options_allowed(self, rw_repo):
10021002
asserttmp_file.exists()
10031003
tmp_file.unlink()
10041004

1005+
@with_rw_and_rw_remote_repo("0.1.6")
1006+
deftest_fetch_unsafe_branch_name(self,rw_repo,remote_repo):
1007+
# Create branch with a name containing a NBSP
1008+
bad_branch_name=f"branch_with_{chr(160)}_nbsp"
1009+
Head.create(remote_repo,bad_branch_name)
1010+
1011+
# Fetch and get branches
1012+
remote=rw_repo.remote("origin")
1013+
branches=remote.fetch()
1014+
1015+
# Test for truncated branch name in branches
1016+
assertf"origin/{bad_branch_name}"in [b.nameforbinbranches]
1017+
1018+
# Cleanup branch
1019+
Head.delete(remote_repo,bad_branch_name)
10051020

10061021
classTestTimeouts(TestBase):
10071022
@with_rw_repo("HEAD",bare=False)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp