misc: Run pre-commit run on all files in repo

The following command was run:

```
pre-commit run --all-files
```

This ensures all the files in the repository are formatted to pass our
checks.

Change-Id: Ia2fe3529a50ad925d1076a612d60a4280adc40de
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/62572
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
Bobby R. Bruce
2022-08-22 12:34:19 -07:00
committed by Bobby Bruce
parent 64add0e04d
commit 2bc5a8b71a
181 changed files with 1445 additions and 1229 deletions

View File

@@ -50,15 +50,20 @@ to ensure that your code follows gem5's style rules on git commit.
This script will now install the hook in your .git/hooks/ directory.
Press enter to continue, or ctrl-c to abort: """
def install_style_hooks(env):
try:
gitdir = env.Dir(gem5_scons.util.readCommand(
["git", "rev-parse", "--git-dir"]).strip("\n"))
gitdir = env.Dir(
gem5_scons.util.readCommand(
["git", "rev-parse", "--git-dir"]
).strip("\n")
)
except Exception as e:
print("Warning: Failed to find git repo directory: %s" % e)
return
git_hooks = gitdir.Dir("hooks")
def hook_exists(hook_name):
hook = git_hooks.File(hook_name)
return hook.exists()
@@ -66,8 +71,9 @@ def install_style_hooks(env):
def hook_install(hook_name, script):
hook = git_hooks.File(hook_name)
if hook.exists():
print("Warning: Can't install %s, hook already exists." %
hook_name)
print(
"Warning: Can't install %s, hook already exists." % hook_name
)
return
if hook.islink():
@@ -78,15 +84,17 @@ def install_style_hooks(env):
os.mkdir(git_hooks.get_abspath())
git_hooks.clear()
abs_symlink_hooks = git_hooks.islink() and \
os.path.isabs(os.readlink(git_hooks.get_abspath()))
abs_symlink_hooks = git_hooks.islink() and os.path.isabs(
os.readlink(git_hooks.get_abspath())
)
# Use a relative symlink if the hooks live in the source directory,
# and the hooks directory is not a symlink to an absolute path.
if hook.is_under(env.Dir("#")) and not abs_symlink_hooks:
script_path = os.path.relpath(
os.path.realpath(script.get_abspath()),
os.path.realpath(hook.Dir(".").get_abspath()))
os.path.realpath(hook.Dir(".").get_abspath()),
)
else:
script_path = script.get_abspath()
@@ -99,8 +107,8 @@ def install_style_hooks(env):
if hook_exists("pre-commit") and hook_exists("commit-msg"):
return
print(git_style_message, end=' ')
if SCons.Script.GetOption('install_hooks'):
print(git_style_message, end=" ")
if SCons.Script.GetOption("install_hooks"):
print("Installing revision control hooks automatically.")
else:
try:
@@ -115,9 +123,11 @@ def install_style_hooks(env):
hook_install("pre-commit", git_style_script)
hook_install("commit-msg", git_msg_script)
def generate(env):
if exists(env) and not gem5_scons.util.ignore_style():
install_style_hooks(env)
def exists(env):
return env.Entry('#.git').exists()
return env.Entry("#.git").exists()