浏览代码

Redo dotnet format (#5119)

/develop/input-actuator-tanks
GitHub 3 年前
当前提交
a813e1c3
共有 4 个文件被更改,包括 7 次插入27 次删除
  1. 1
      .github/workflows/pre-commit.yml
  2. 7
      .pre-commit-config.yaml
  3. 2
      com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs
  4. 24
      utils/run_dotnet_format.py

1
.github/workflows/pre-commit.yml


- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
- run: dotnet tool install -g dotnet-format --version 4.1.131201
- uses: pre-commit/action@v2.0.0
markdown-link-check:

7
.pre-commit-config.yaml


types: [markdown]
exclude: ".*localized.*"
- repo: https://github.com/dotnet/format
rev: "7e343070a0355c86f72bdee226b5e19ffcbac931" # TODO - update to a tagged version when one that includes the hook is ready.
hooks:
- id: dotnet-format
args: [--folder, --include]
# "Local" hooks, see https://pre-commit.com/#repository-local-hooks
- repo: local
hooks:

name: validate release links
language: script
entry: utils/validate_release_links.py

2
com.unity.ml-agents/Runtime/Communicator/GrpcExtensions.cs


/// <returns>The protobuf version of the AgentInfo.</returns>
public static AgentInfoProto ToAgentInfoProto(this AgentInfo ai)
{
if(ai.groupId > 0)
if (ai.groupId > 0)
{
var trainerCanHandle = Academy.Instance.TrainerCapabilities == null || Academy.Instance.TrainerCapabilities.MultiAgentGroups;
if (!trainerCanHandle)

24
utils/run_dotnet_format.py


#!/usr/bin/env python3
import argparse
import os
import subprocess
import tempfile
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("files", nargs="*")
args = parser.parse_args()
with tempfile.TemporaryDirectory() as tempdir:
# Could potentially hit the commandline limit, so write files to a response file
# See https://github.com/dotnet/format/issues/699
resp_file = os.path.join(tempdir, "response.txt")
with open(resp_file, "w") as fp:
for f in args.files:
fp.write(f + "\n")
subprocess_args = ["dotnet", "format", "--folder", "--include", f"@{resp_file}"]
subprocess.check_call(subprocess_args)
正在加载...
取消
保存