A tool to check problems about meta files of Unity

Overview

Unity meta checker

A tool to check problems about meta files of Unity on Git repositories, and also the tool can do limited autofix for meta files of auto-generated files.

This tool can check the following problems:

Missing meta files
Missing means that an asset should have a meta file but the meta file is not committed. This problem can cause broken asset references.
Dangling meta files
Dangling means that a meta file exist, but the asset is not committed. This problem can cause annoying warning messages.

Basic Usage

$ # Change the current directory to your Unity project or UPM package.
$ cd /path/to/unity/project

$ # Execute unity-meta-check (specifying -silent make that unity-meta-check only show results or fatal errors).
$ unity-meta-check -silent
missing: Assets/Not/Added.meta
missing: Packages/com.my.pkg/README.meta
missing: LocalPackages/com.local.pkg/README.meta
...
dangling: Assets/Not/Removed.meta
dangling: Packages/com.my.pkg/MyPkg.csproj.meta
dangling: LocalPackages/com.local.pkg/LocalPkg.csproj.meta
...

$ # unity-meta-check exit with non-zero status if one or more missing/dangling .meta files exist.
$ echo $?
1

Typically, unity-meta-check don't need to specify the target type (Unity project or UPM package) because unity-meta-check can automatically detect it. You can explicitly specify -unity-project or -upm-package to disable the automatic detection, if the detection result was not intended.

If you want to ignore some problems, you can use .meta-check-ignore (this format is very similar to .gitignore but ! is not supported):

$ unity-meta-check -silent
missing: Assets/Not/Added1.meta
missing: Assets/NotAdded2.meta

$ # You can ignore these problems using .meta-check-ignore:
$ cat .meta-check-ignore
Assets/Not             # All files in the directory or the sub directories get ignored.
Assets/NotAdded2.meta  # Also can specify the path to files.

$ # unity-meta-check will ignore these problems.
$ unity-meta-check -silent

See more advanced usage for more information.

Installation

Using Docker Image

This way is recommended to use unity-meta-check on CI.

$ docker pull docker.pkg.github.com/dena/unity-meta-check/unity-meta-check:latest
$ docker run -it --rm docker.pkg.github.com/dena/unity-meta-check/unity-meta-check:latest -help

Using Git Submodules

You can add unity-meta-check-bins as submodule into your git repository. This way is useful to ensure to use the same unity-meta-check version on CI or manual execution.

$ cd /path/to/your/repo
$ git add submodule [email protected]:dena/unity-meta-check-bins ./path/to/unity-meta-check-bins

$ ./path/to/unity-meta-check-bins/unity-meta-check-easy -help

Download binaries

Binaries are available on releases.

Advanced Usage

Provided features are built on several individual binaries:

unity-meta-check
Checker for missing/dangling meta files. The result print to stdout.
unity-meta-check-autofix
Autofix for meta files problems. It need a result of unity-meta-check via stdin.
unity-meta-check-junit
Reporter for Jenkins compatible XML based JUnit reports. It need a result of unity-meta-check from stdin.
unity-meta-check-github-pr-comment
Reporter for GitHub comments of GitHub issues or pull requests. It need a result of unity-meta-check from stdin.

unity-meta-check

unity-meta-check checks missing/dangling meta files on the commit.

This check based on a git tree object instead of the working directory. It means you MUST commit adding missing meta files or removing dangling meta files to re-check by unity-meta-check.

Other complemental features such as autofix or reporting are provided other binaries.

$ unity-meta-check -help
usage: unity-meta-check [] []

Check missing or dangling .meta files.

  
        root directory of your Unity project or UPM package to check (default "$(git rev-parse --show-toplevel)")

OPTIONS
  -debug
        set log level to DEBUG (default INFO)
  -ignore-file string
        path to .meta-check-ignore
  -ignore-dangling
        ignore dangling .meta
  -ignore-submodules
        ignore git submodules and nesting repositories (this is RECOMMENDED but not enabled by default because it can cause to miss problems in submodules or nesting repositories)
  -no-ignore-case
        treat case of file paths
  -silent
        set log level to WARN (default INFO)
  -unity-project
        check as Unity project
  -unity-project-sub-dir
        check as sub directory of Unity project
  -upm-package
        check as UPM package (same meaning of -unity-project-sub-dir)
  -version
        print version

EXAMPLE USAGES
  $ cd path/to/UnityProject
  $ unity-meta-check -silent

  $ cd path/to/any/dir
  $ unity-meta-check -silent -upm-package path/to/MyUPMPackage
  $ unity-meta-check -silent -unity-project-sub-dir path/to/UnityProject/Assets/Sub/Dir

EXAMPLE USAGES WITH OTHER TOOLS
  $ unity-meta-check  | unity-meta-check-junit path/to/junit.xml
  $ unity-meta-check  | unity-meta-check-github-pr-comment 
  $ unity-meta-check  | unity-meta-check-junit path/to/junit.xml | unity-meta-check-github-pr-comment 

If both -silent and -debug are specified, -silent win.

unity-meta-autofix

unity-meta-autofix fix (very limited) problems about meta files. It needs a result of unity-meta-check via stdin. It can fix the following problems:

Missing meta files for folders
Example of auto-generated meta files
fileFormatVersion: 2
guid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
folderAsset: yes
DefaultImporter:
  externalObjects: {}
  userData: 
  assetBundleName: 
  assetBundleVariant: 

Automatic GUID generation does not depend on time, so it is safe if autofix runs parallel.

Missing meta files for some binaries
Sometimes you need to import auto-generated binary data files (like encoded as Protocol Buffer Binary Wire Format) programmatically. Then, autofix feature is useful because it can add meta files to the binaries.
Example of auto-generated meta files
guid: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TextScriptImporter:
  externalObjects: {}
  userData: 
  assetBundleName: 
  assetBundleVariant: 

Automatic GUID generation does not depend on time, so it is safe if autofix runs parallel.

$ unity-meta-autofix -help
usage: unity-meta-autofix []  [...]

Fix missing or dangling .meta. Currently autofix is only limited support.

ARGUMENTS
  
        glob pattern to path where autofix allowed on

OPTIONS
  -debug
        set log level to DEBUG (default INFO)
  -dry-run
        dry run
  -fix-dangling
        fix dangling .meta
  -fix-missing
        fix missing .meta
  -root-dir string
        directory path to where unity-meta-check checked at (default ".")
  -silent
        set log level to WARN (default INFO)
  -version
        print version

EXAMPLE USAGES
  $ unity-meta-check  | unity-meta-autofix -dry-run -fix-missing -fix-dangling path/to/autofix
  $ unity-meta-check  | unity-meta-autofix  | 

Currently, autofix for dangling meta files is not supported, because it might be dangerous on some situations.

unity-meta-check-junit

unity-meta-check-junit is a reporter for Jenkins compatible XML based JUnit reports. It needs a result of unity-meta-check via stdin.

$ unity-meta-check-junit -help
usage: unity-meta-check-junit [] []

Save a JUnit report file for the result from unity-meta-check via STDIN.

  
        output path to write JUnit report

OPTIONS
  -version
        print version

EXAMPLE USAGES
  $ unity-meta-check  | unity-meta-check-junit path/to/junit-report.xml
  $ unity-meta-check  | unity-meta-check-junit path/to/junit-report.xml | 

unity-meta-check-github-pr-comment

unity-meta-check-github-pr-comment is a reporter for GitHub comments of GitHub issues or pull requests. It needs a result of unity-meta-check via stdin.

$ unity-meta-check-github-pr-comment -help
usage: unity-meta-check-github-pr-comment []

Post a comment for the result from unity-meta-check via STDIN to GitHub Pull Request.

OPTIONS
  -api-endpoint string
        GitHub API endpoint URL (like https://github.example.com/api/v3) (default "https://api.github.com")
  -debug
        set log level to DEBUG (default INFO)
  -lang string
        language code (available: en, ja) (default "en")
  -owner string
        owner of the GitHub repository
  -pull uint
        pull request number
  -repo string
        name of the GitHub repository
  -silent
        set log level to WARN (default INFO)
  -template-file string
        custom template file
  -version
        print version

ENVIRONMENT
  GITHUB_TOKEN
        GitHub API token. The scope can be empty if your repository is public. Otherwise, the scope should contain "repo"

EXAMPLE USAGES
  $ export GITHUB_TOKEN="********"
  $ unity-meta-check  | unity-meta-check-github-pr-comment \
      -api-endpoint https://api.github.com \
      -owner example-org \
      -repo my-repo \
      -pull "$CIRCLE_PR_NUMBER"  # This is for CircleCI

  $ export GITHUB_TOKEN="********"  # This should be set via credentials().
  $ unity-meta-check  | unity-meta-check-github-pr-comment \
      -api-endpoint https://github.example.com/api/v3 \
      -owner example-org \
      -repo my-repo \
      -pull "$ghprbPullId"  # This is for Jenkins with GitHub PullRequest Builder plugin

  $ GITHUB_TOKEN="********" unity-meta-check  | unity-meta-check-junit path/to/unity-meta-check-result.xml | unity-meta-check-github-pr-comment  | 

  $ export GITHUB_TOKEN="********"  # This should be set via credentials().
  $ unity-meta-check  | unity-meta-check-github-pr-comment \
      -api-endpoint https://github.example.com/api/v3 \
      -owner example-org \
      -repo my-repo \
      -pull "$ghprbPullId" \
      -template-file path/to/template.json  # template file can be used for localization for GitHub comments.

TEMPLATE FILE FORMAT EXAMPLE
  If a template file is like:

  {
    "success": "No missing/dangling .meta found. Perfect!",
    "failure": "Some missing or dangling .meta found. Fix commits are needed.",
    "header_status": "Status",
    "header_file_path": "File",
    "status_missing": "Not committed",
    "status_dangling": "Not removed"
  }

  then the output become:

  No missing/dangling .meta found. Perfect!

  or:

  Some missing or dangling .meta found. Fix commits are needed.

  | Status | File |
  |:--|:--|
  | Not committed | `path/to/missing.meta` |
  | Not removed | `path/to/dangling.meta` |
Comments
  • [add] macOS test and matrix flow in CI

    [add] macOS test and matrix flow in CI

    I changed a bit for test.yml

    CHANGING

    • use matrix about testing os
    • add macOS test

    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by get-me-power 2
  • feature(gen): add MonoImporter

    feature(gen): add MonoImporter

    Add support for autofixing missing .cs.meta files, using the default unity content.

    Also, as a side note, there is no image tagged with latest as stated in the Installation part of the readme:

    $ docker pull ghcr.io/dena/unity-meta-check/unity-meta-check:latest
    Error response from daemon: name unknown
    

    This should be reported as an issue, but since you have that turned off...


    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by piksel 2
  • Fixed missing command in README

    Fixed missing command in README

    I fixed git submodule command's writing in README


    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by get-me-power 1
  • Support '.asmdef'

    Support '.asmdef'

    • Support .asmdef extension on autofix

    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by dev-jelly 1
  • Creating major version branch name with pre-release

    Creating major version branch name with pre-release

    • Upgrade check-version-format-action v3
    • Using output major_prerelease for branch name
    • Fix create major and latest branch. see https://r7kamura.com/articles/2022-04-16-keep-main-version-branch

    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by nowsprinting 1
  • Can work on issue_comment events as

    Can work on issue_comment events as "trigger phrase"

    Support a feature like "trigger phrase" of GitHubPullRequestBuilder on GitHub Actions.

    name: Meta Check
    on:
      pull_request:
      issue_comment:
        types: [created, edited]
    
    jobs:
      meta-check:
        # NOTE: Check every push to pull requests and re-check if "meta-check" commented to pull requests.
        if: github.event.pull_request || (github.event.comment && contains(github.event.comment.body, 'meta-check'))
        runs-on: ubuntu-latest
        steps:
          - uses: actions/[email protected]
          - uses: DeNA/[email protected]
            with:
              enable_pr_comment: true
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    
    opened by Kuniwak 1
  • Add missing steps of deploy procedure

    Add missing steps of deploy procedure

    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by Kuniwak 0
  • Use branches instead of tags

    Use branches instead of tags


    Contribution License Agreement

    • [x] By placing an "x" in the box, I hereby understand, accept and agree to be bound by the terms and conditions of the Contribution License Agreement.
    opened by Kuniwak 0
  • Add create major version and latest tag workflow

    Add create major version and latest tag workflow

    • Add workflow about update major-version and latest tag when tagged
    • Fix GitHub Actions workflow example

    refs https://github.com/actions/toolkit/blob/master/docs/action-versioning.md#versioning

    opened by nowsprinting 0
Releases(v3.1.2)
Owner
DeNA
Delight and Impact the World
DeNA
Split multiple Kubernetes files into smaller files with ease. Split multi-YAML files into individual files.

kubectl-slice: split Kubernetes YAMLs into files kubectl-slice is a neat tool that allows you to split a single multi-YAML Kubernetes manifest into mu

Patrick D'appollonio 205 Jan 3, 2023
A full-featured license tool to check and fix license headers and resolve dependencies' licenses.

SkyWalking Eyes A full-featured license tool to check and fix license headers and resolve dependencies' licenses. Usage You can use License-Eye in Git

The Apache Software Foundation 183 Dec 26, 2022
Go linter to check the struct literal to use field name

Structfield Find struct literals using non-labeled fields. The structfield analysis reports the usage of struct literal using non-labeled fields more

Nuruddin Ashr 3 Aug 23, 2021
Log4j check with golang

log4jcheck Install go install github.com/michael1026/[email protected] Example Usage cat URLs | log4jcheck -user-agent -referer -server example.burpc

Michael Blake 0 Dec 11, 2021
a tool for creating exploited media files for discord

Discord-Exploits A program for creating exploited media files for discord written in Go. Usage discord-exploits is a command line utility, meaning you

schmenn 219 Dec 29, 2021
🔍 A jq-like tool that queries files via glob.

?? fq A jq-like tool that queries files via glob. ✅ Prerequisites Go 1.17+ jq (installed and on PATH) ?? Installation $ go get github.com/siketyan/fq

Naoki Ikeguchi 5 Dec 22, 2021
Small tool for splitting files found in a path into multiple groups

Small tool for splitting files found in a path into multiple groups. Usefull for parallelisation of whatever can be paralleled with multiple files.

Antonio Martinović 0 Jan 30, 2022
ssdt - Survey security.txt files

ssdt - Survey security.txt files A program to quickly survey security.txt files found on the Alexa Top 1 Million websites. The program takes about 15

null 82 Oct 31, 2022
libraries for various programming languages that make it easy to generate per-process trace files that can be loaded into chrome://tracing

chrometracing: chrome://tracing trace_event files The chrometracing directory contains libraries for various programming languages that make it easy t

Google 23 Oct 6, 2022
A program for extracting information from chrome session files.

What A tool for dumping the contents of chrome session files. Why? Most tools for reading SNSS files (chrome session files) are either broken or outda

null 42 Nov 23, 2022
Small utility to allow simpler, quicker testing of parsing files in crowdsec

cs_parser_test Small utility to allow simpler, quicker testing of parsing files in crowdsec Usage $ sudo cs_parser_test -t syslog /var/log/mail.log N

david reid 3 Jul 13, 2021
a sharded store to hold large IPLD graphs efficiently, packaged as location-transparent attachable CAR files, with mechanical sympathy

DAG store This README will be populated soon. In the meantime, please refer to the design document.

Filecoin 33 Oct 31, 2022
LogAnalyzer - Analyze logs with custom regex patterns.Can search for particular patterns on multiple files in a directory.

LogAnalyzer Analyze logs with custom regex patterns.Can search for particular patterns on multiple files in a directory

Johnson Simon 6 May 31, 2022
Helm plugin to reference value files packaged in dependency charts

Helm Octopus Plugin This Helm plugin allows to reference packaged value files (other than the default values.yaml). Install helm plugin install https:

Softonic 3 Sep 23, 2021
Hex dump and read values of files quickly and swiftly with Go-Hex a program designed to dump any file in a hexadecimal format

Go-Hex Hex dump and read values of files quickly and swiftly with Go-Hex a program designed to dump any file in a hexadecimal format Dump Hashes ----

RE43P3R 0 Oct 10, 2021
Package macho implements access to and creation of Mach-O object files.

go-macho [WIP] ?? Package macho implements access to and creation of Mach-O object files. Why ?? This package goes beyond the Go's debug/macho to: Cov

Bogdan Donchenko 7 Sep 2, 2022
A utility library to do files/io/bytes processing/parsing in file-system or network.

goreader A utility library to do files/io/bytes processing/parsing in file-system or network. These features are really common to be implemented for a

VOrishirne 4 Nov 1, 2021
Go-library that facilitates the usage of .env files

Goenv Golang-library that facilitates the use of .env files. Installation go get github.com/fabioelizandro/goenv Usage Place a .env file in the root

Fabio Elizandro 1 Nov 7, 2021
Backme - A backup files organizer

backme --- A backup files organizer Quite often big files (like database dumps)

Species File Group 0 Jan 26, 2022