Skip to content

Commit d294145

Browse files
Théo Penavairetheo-at-unity
authored andcommitted
Hooks fixes and improvements from feedback (#2990)
* Update python requirement to 3.6 * Force LF on all files * Update Tools readme * Update git hooks revision
1 parent f7410ad commit d294145

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
* text=auto
1+
* text=auto eol=lf
22

33
# Unity assets are always serialized using lf endings
44
LightingData.asset binary

Tools/.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
default_stages: [commit]
22
repos:
33
- repo: git@github.cds.internal.unity3d.com:theo-penavaire/gfx-automation-tools.git
4-
rev: 3b07dd9872a652b6170b9031d42e997714733314
4+
rev: 892e7fb
55
hooks:
66
- id: file-extension-to-lowercase
77
- id: check-shader-includes

Tools/readme.md

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents**
4+
5+
- [Tools](#tools)
6+
- [Git-hooks](#git-hooks)
7+
- [Installation](#installation)
8+
- [Available hooks](#available-hooks)
9+
- [FAQ and Troubleshooting steps](#faq-and-troubleshooting-steps)
10+
- [Formatting](#formatting)
11+
12+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
13+
114
# Tools
215

316
_Questions: #devs-graphics-automation_
@@ -12,17 +25,15 @@ For example, compliance with Unity's code convention is mandatory in order to me
1225

1326
Follow these steps to install the git hooks before working on the Graphics repository:
1427

15-
1. Requirement A: Install [Python >= 3.5](https://www.python.org/downloads/) and make sure it is accessible in your PATH.
16-
2. Requirement B: Install [pip3](https://pip.pypa.io/en/stable/installing/).
17-
3. Requirement C: Make sure [unity-meta](https://internaldocs.hq.unity3d.com/unity-meta/setup/) is installed and its requirements are fulfilled. It will be used by the format code hook to ensure your code complies with the convention. _Sidenote: it is the same tool used to format C++/trunk code._
18-
4. Requirement D: Make sure you have access to the cds.github.com repositories. Usually this means following [these steps](https://docs.github.com/en/enterprise-server@2.21/github/authenticating-to-github/connecting-to-github-with-ssh) to create and upload an ssh key to [cds.github.com](https://github.cds.internal.unity3d.com/settings/keys).
28+
1. Install [Python >= 3.6](https://www.python.org/downloads/) and make sure it is accessible in your PATH.
29+
2. Install [pip3](https://pip.pypa.io/en/stable/installing/).
30+
3. Make sure [unity-meta](https://internaldocs.hq.unity3d.com/unity-meta/setup/) is installed and its requirements are fulfilled. It will be used by the format code hook to ensure your code complies with the convention. _Sidenote: it is the same tool used to format C++/trunk code._
31+
4. Make sure you have access to the cds.github.com repositories. Usually this means following [these steps](https://docs.github.com/en/enterprise-server@2.21/github/authenticating-to-github/connecting-to-github-with-ssh) to create and upload an ssh key to [cds.github.com](https://github.cds.internal.unity3d.com/settings/keys).
1932
5. From the root of the repository, run `cd Tools` and `python3 ./hooks_setup.py`.
2033

21-
Note: If you already installed the git hooks (before November 2020), you need to follow the steps above to re-install them. This is required in order to move towards a more scalable and flexible system. _Sidenote: NodeJS and the node_modules folder are no longer required._
22-
2334
### Available hooks
2435

25-
A description of the hooks we currently have is available in the [hooks' library repository](https://github.cds.internal.unity3d.com/theo-penavaire/gfx-automation-tools#available-git-hooks).
36+
A description of the hooks we currently have is available in the [hooks library repository](https://github.cds.internal.unity3d.com/theo-penavaire/gfx-automation-tools#available-git-hooks).
2637

2738
For this repository we have enabled:
2839

@@ -75,7 +86,7 @@ Last resort: [Troubleshooting SSH section in Github docs](https://docs.github.co
7586

7687
**Python or pre-commit not found, even if python is installed, "/usr/bin/env: ‘python’: Permission denied"**
7788

78-
Make sure Python (>=3.5) is in your PATH. Commands that can help:
89+
Make sure Python (>=3.6) is in your PATH. Commands that can help:
7990
- On windows: `where python3`
8091
- On Unix: `which python3`
8192
- [How to add to the path on Windows10?](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/)
@@ -101,3 +112,15 @@ Follow the suggestions of [this StackOverflow answer](https://stackoverflow.com/
101112
**Can't locate Win32/Process.pm in @INC...**
102113

103114
On Windows, Active perl is not supported by the formatting tool. Use Strawberry perl.
115+
116+
## Formatting
117+
118+
Provided you installed [unity-meta](https://internaldocs.hq.unity3d.com/unity-meta/setup/), you can manually run the formatting tool with the following command (use powershell on windows):
119+
```
120+
perl ~/unity-meta/Tools/Format/format.pl --hgroot $(pwd) --dry-run <folder to format>
121+
```
122+
To actually apply the changes:
123+
```
124+
perl ~/unity-meta/Tools/Format/format.pl --hgroot $(pwd) --nobackups <folder to format>
125+
```
126+
Use `--help` to discover more useful options (`--preview` will generate a diff file for instance)

0 commit comments

Comments
 (0)