Skip to content

Commit

Permalink
Temp update
Browse files Browse the repository at this point in the history
  • Loading branch information
Javagedes committed Oct 24, 2023
1 parent b2a1e23 commit 36c1015
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions edk2toollib/gitignore_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import collections
import os
import re
import sys
from os.path import abspath, dirname
from pathlib import Path
from typing import Union
Expand Down Expand Up @@ -182,7 +183,8 @@ def match(self, abs_path):
else:
rel_path = str(_normalize_path(abs_path))

Check warning on line 184 in edk2toollib/gitignore_parser.py

View check run for this annotation

Codecov / codecov/patch

edk2toollib/gitignore_parser.py#L184

Added line #L184 was not covered by tests

rel_path += " " * _count_trailing_whitespace(abs_path)
if sys.platform.startswith('win'):
rel_path += " " * _count_trailing_whitespace(abs_path)
# Path() strips the trailing slash, so we need to preserve it
# in case of directory-only negation
if self.negation and isinstance(abs_path, str) and abs_path[-1] == '/':
Expand Down Expand Up @@ -279,4 +281,5 @@ def _count_trailing_whitespace(text: str):
if char.isspace():
count += 1
else:
return count
break
return count
8 changes: 5 additions & 3 deletions tests.unit/parsers/test_gitingore_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,18 @@ def test_symlink_to_another_directory():
This test ensures that the issue is now fixed.
"""
with tempfile.TemporaryDirectory() as project_dir, tempfile.TemporaryDirectory() as another_dir:
gitignore_path = Path(project_dir, ".gitignore")
project_dir = Path(project_dir).resolve()
another_dir = Path(another_dir).resolve()
gitignore_path = project_dir / ".gitignore"

with open(gitignore_path, 'w') as f:
f.write('link\n')

rule_tester = gitignore_parser.parse_gitignore_file(gitignore_path, base_dir=project_dir)

# Create a symlink to another directory.
link = Path(project_dir, 'link')
target = Path(another_dir, 'target')
link = project_dir / 'link'
target = another_dir / 'target'
try:
link.symlink_to(target)
except OSError: # Missing permissions to do a symlink
Expand Down

0 comments on commit 36c1015

Please sign in to comment.