Skip to content
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

Plugin/LineEndingCheck: Add autocrlf warning #260

Merged
Merged
Changes from all 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
22 changes: 21 additions & 1 deletion .pytool/Plugin/LineEndingCheck/LineEndingCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from edk2toollib.log.junit_report_format import JunitReportTestCase
from edk2toollib.uefi.edk2.path_utilities import Edk2Path
from edk2toollib.utility_functions import RunCmd
from git import Repo


PLUGIN_NAME = "LineEndingCheck"

Expand Down Expand Up @@ -84,6 +86,24 @@ def GetTestName(self, packagename: str, environment: VarDict) -> Tuple:
return ("Check line endings in " + packagename, packagename +
"." + PLUGIN_NAME)

# Note: This function access git via the command line
#
# function to check and warn if git config reports that
# autocrlf is configured to TRUE
apop5 marked this conversation as resolved.
Show resolved Hide resolved
def _check_autocrlf(self):
r = Repo(".")
try:
result = r.config_reader().get_value("core", "autocrlf")
if result:
logging.warning(f"git config core.autocrlf is set to {result} "
f"recommended setting is false "
f"git config --global core.autocrlf false")
except:
logging.warning(f"git config core.autocrlf is not set "
f"recommended setting is false "
f"git config --global core.autocrlf false")
return

# Note: This function currently accesses git via the git command to prevent
# introducing a new Python git module dependency in mu_basecore
# on gitpython.
Expand Down Expand Up @@ -228,7 +248,7 @@ def RunBuildPlugin(self, package_rel_path: str, edk2_path: Edk2Path,
0 : Ran successfully
-1 : Skipped due to a missing pre-requisite
"""

self._check_autocrlf()
self._abs_workspace_path = \
edk2_path.GetAbsolutePathOnThisSystemFromEdk2RelativePath('.')
self._abs_pkg_path = \
Expand Down