Skip to content

Commit

Permalink
Git attributes change (tianocore#8)
Browse files Browse the repository at this point in the history
* add git attributes file to align EOL mgmt
* Update EOL to be consistent
  • Loading branch information
spbrogan authored Aug 5, 2019
1 parent edb39d8 commit bbe2882
Show file tree
Hide file tree
Showing 13 changed files with 359 additions and 300 deletions.
59 changes: 59 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
* text=auto

*.md text
*.txt text

# Graphics
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.tif binary
*.tiff binary
*.ico binary
# SVG treated as an asset (binary) by default.
*.svg text

# Scripts
*.bash text eol=lf
*.sh text eol=lf
# These are explicitly windows files and should use crlf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf

# Serialisation
*.json text
*.toml text
*.xml text
*.yaml text
*.yml text

# Archives
*.7z binary
*.gz binary
*.tar binary
*.zip binary
*.exe binary

#
# Exclude files from exporting
#

.gitattributes export-ignore
.gitignore export-ignore


# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyc text diff=python
*.pyd text diff=python
*.pyo text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
160 changes: 80 additions & 80 deletions BasicDevTests.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
##
# Quick script to check that python code in the package
# aligns with pep8 and file encoding. I have not found
# a way to enforce that with tools like flake8
#
# There must be a better way. :)
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

import glob
import os
import sys
import logging


def TestEncodingOk(apath, encodingValue):
try:
with open(apath, "rb") as fobj:
fobj.read().decode(encodingValue)
except Exception as exp:
logging.critical("Encoding failure: file: {0} type: {1}".format(apath, encodingValue))
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath))
return False
return True


def TestFilenameLowercase(apath):
if apath != apath.lower():
logging.critical(f"Lowercase failure: file {apath} not lower case path")
logging.error(f"\n\tLOWERCASE: {apath.lower()}\n\tINPUTPATH: {apath}")
return False
return True


def TestNoSpaces(apath):
if " " in apath:
logging.critical(f"NoSpaces failure: file {apath} has spaces in path")
return False
return True


def TestRequiredLicense(apath):
lic = ["SPDX-License-Identifier: BSD-2-Clause-Patent"]
try:
with open(apath, "rb") as fobj:
contents = fobj.read().decode()
found = False
for l in lic:
if l in contents:
found = True
break
if not found:
logging.critical(f"License failure: file {apath} has incorrect, invalid, or unsupported license")
return False
except Exception as exp:
logging.critical(f"License failure: Exception trying to read file: {apath}")
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath))
return False
return True


p = os.path.join(os.getcwd(), "edk2toollib")
pyfiles = glob.glob(os.path.join(p, "**", "*.py"), recursive=True)
error = 0
for a in pyfiles:
aRelativePath = os.path.relpath(a, os.getcwd())
if(not TestEncodingOk(a, "ascii")):
error += 1
if(not TestFilenameLowercase(aRelativePath)):
error += 1
if(not TestNoSpaces(aRelativePath)):
error += 1
if(not TestRequiredLicense(a)):
error += 1

logging.critical(f"Found {error} error(s) in {len(pyfiles)} file(s)")
sys.exit(error)
##
# Quick script to check that python code in the package
# aligns with pep8 and file encoding. I have not found
# a way to enforce that with tools like flake8
#
# There must be a better way. :)
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

import glob
import os
import sys
import logging


def TestEncodingOk(apath, encodingValue):
try:
with open(apath, "rb") as fobj:
fobj.read().decode(encodingValue)
except Exception as exp:
logging.critical("Encoding failure: file: {0} type: {1}".format(apath, encodingValue))
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath))
return False
return True


def TestFilenameLowercase(apath):
if apath != apath.lower():
logging.critical(f"Lowercase failure: file {apath} not lower case path")
logging.error(f"\n\tLOWERCASE: {apath.lower()}\n\tINPUTPATH: {apath}")
return False
return True


def TestNoSpaces(apath):
if " " in apath:
logging.critical(f"NoSpaces failure: file {apath} has spaces in path")
return False
return True


def TestRequiredLicense(apath):
lic = ["SPDX-License-Identifier: BSD-2-Clause-Patent"]
try:
with open(apath, "rb") as fobj:
contents = fobj.read().decode()
found = False
for l in lic:
if l in contents:
found = True
break
if not found:
logging.critical(f"License failure: file {apath} has incorrect, invalid, or unsupported license")
return False
except Exception as exp:
logging.critical(f"License failure: Exception trying to read file: {apath}")
logging.error("EXCEPTION: while processing {1} - {0}".format(exp, apath))
return False
return True


p = os.path.join(os.getcwd(), "edk2toollib")
pyfiles = glob.glob(os.path.join(p, "**", "*.py"), recursive=True)
error = 0
for a in pyfiles:
aRelativePath = os.path.relpath(a, os.getcwd())
if(not TestEncodingOk(a, "ascii")):
error += 1
if(not TestFilenameLowercase(aRelativePath)):
error += 1
if(not TestNoSpaces(aRelativePath)):
error += 1
if(not TestRequiredLicense(a)):
error += 1

logging.critical(f"Found {error} error(s) in {len(pyfiles)} file(s)")
sys.exit(error)
54 changes: 27 additions & 27 deletions ConfirmVersionAndTag.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
## @file
# Quick script to check that the wheel/package created is aligned on a git tag.
# Official releases should not be made from non-tagged code.
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

import glob
import os
import sys

p = os.path.join(os.getcwd(), "dist")
whlfile = glob.glob(os.path.join(p, "*.whl"))
if(len(whlfile) != 1):
for filename in whlfile:
print(filename)
raise Exception("Too many wheel files")
rfn = os.path.relpath(whlfile[0], os.getcwd())
v = rfn.split("-")[1]
if v.count(".") != 2:
raise Exception("Version %s not in format major.minor.patch" % v)
if "dev" in v:
raise Exception("No Dev versions allowed to be published.")
print("version: " + str(v))
sys.exit(0)
## @file
# Quick script to check that the wheel/package created is aligned on a git tag.
# Official releases should not be made from non-tagged code.
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##

import glob
import os
import sys

p = os.path.join(os.getcwd(), "dist")
whlfile = glob.glob(os.path.join(p, "*.whl"))
if(len(whlfile) != 1):
for filename in whlfile:
print(filename)
raise Exception("Too many wheel files")
rfn = os.path.relpath(whlfile[0], os.getcwd())
v = rfn.split("-")[1]
if v.count(".") != 2:
raise Exception("Version %s not in format major.minor.patch" % v)
if "dev" in v:
raise Exception("No Dev versions allowed to be published.")
print("version: " + str(v))
sys.exit(0)
14 changes: 7 additions & 7 deletions edk2toollib/bin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/log/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/tpm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/uefi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/uefi/edk2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/uefi/edk2/parsers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/windows/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
14 changes: 7 additions & 7 deletions edk2toollib/windows/capsule/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
##
# File to mark this a python package
#
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
Loading

0 comments on commit bbe2882

Please sign in to comment.