Coder Social home page Coder Social logo

unity-git-hooks's Introduction

Unity Git Hooks

Git hooks for Unity project.

To manage a Unity project, the Assets meta file should also been added to repository. But sometimes the meta files and the corresponding asset files and directories are inconsistent, then meta files will lead to conflicts when a team is collaborating on the same code base.

Features

  • Stop committing if meta files and asset files and directories are inconsistent. If an asset file is added, its meta file and meta files of all its containing directories should also been added. If a asset file is deleted, its meta file and meta files of all its empty containing directories should also been deleted. When meta files are added/deleted, asset files and directories should also been consistent.
  • Delete empty asset directories after checkout and merge. Unity keep generating meta file for empty asset directory, but git does not trace directory.

Usage

Copy files post-checkout post-merge and pre-commit to .git/hooks in your git repository. If you also have hooks defined in these files, append them to existing files.

It is assumed that Assets directory is located in the root directory of the repository. You doesn't need set path to "Assets" folder manually if you "Assets" folder has position in the same folder as ".git". Example:

.
+-- ProjectName
|   +-- .git
|   +-- Assets

Otherwise you need set full path relative .git. Following example tells the scripts that the assets directory is client/Assets Example:

.
+-- ProjectName
|   +-- .git
|   +-- client
|   |   +-- Assets
git config unity3d.assets-dir client/Assets

unity-git-hooks's People

Contributors

doitian avatar starikcetin avatar vangogih avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-git-hooks's Issues

License Type

Hello! I would love to use this in our project but it is missing the license type. Would you mind adding it?

`Assets.meta' is not in the git index.

In pre-commit script The cycle is designed in such a way that it always checks the existence of the Assets.meta file at the end.

git status
new file:   Assets/Issue.meta
new file:   Assets/Issue/TestScript.cs
new file:   Assets/Issue/TestScript.cs.meta
git commit -m "testScriptCommit"
Error: Missing meta file.
Asset `Assets/Issue/TestScript.cs' is added, but `Assets.meta' is not in the git index.
Please add `Assets.meta' to git as well.

I solved the problem, but not sure what is correct. I added a condition into a while loop after 51 and 89 lines

if [ "$p" = "Assets" ]; then 
	break
fi

Trace log for help.

++ git config --get unity3d.assets-dir
+ ASSETS_DIR=E:/UnityWork/bulletshero/
+ against=HEAD
++ git status --untracked-files=no --porcelain
+ '[' 'A  Assets/Issue.meta
A  Assets/Issue/TestScript.cs
A  Assets/Issue/TestScript.cs.meta' == '' ']'
+ exec
+ echo -e '\e[32m[RUN] start checking .meta files \e[39m'
[RUN] start checking .meta files
+ git diff --cached --name-only --diff-filter=A -z HEAD -- E:/UnityWork/bulletshero/
+ read -d '' f
+ ext=meta
+ base=Assets/Issue
+ '[' meta = meta ']'
++ git ls-files --cached -- Assets/Issue
++ wc -l
+ '[' 2 = 0 ']'
+ read -d '' f
+ ext=cs
+ base=Assets/Issue/TestScript
+ '[' cs = meta ']'
+ p=Assets/Issue/TestScript.cs
+ '[' Assets/Issue/TestScript.cs '!=' E:/UnityWork/bulletshero/ ']'
++ git ls-files --cached -- Assets/Issue/TestScript.cs.meta
++ wc -l
+ '[' 1 = 0 ']'
+ p=Assets/Issue
+ '[' Assets/Issue '!=' E:/UnityWork/bulletshero/ ']'
++ git ls-files --cached -- Assets/Issue.meta
++ wc -l
+ '[' 1 = 0 ']'
+ p=Assets
+ '[' Assets '!=' E:/UnityWork/bulletshero/ ']'
++ git ls-files --cached -- Assets.meta
++ wc -l
+ '[' 0 = 0 ']'
+ cat
Error: Missing meta file.
Asset `Assets/Issue/TestScript.cs' is added, but `Assets.meta' is not in the git index.
Please add `Assets.meta' to git as well.
+ exit 1
+ ret=1
+ '[' 1 '!=' 0 ']'

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.