Commit f2afe4b9 authored by Soraphis's avatar Soraphis
Browse files

updated readme

and added git hooks for unity
parent 30707711
{
"dependencies": {
"com.unity.ads": "2.0.8",
"com.unity.analytics": "2.0.16",
"com.unity.incrementalcompiler": "0.0.42-preview.19",
"com.unity.package-manager-ui": "1.9.11",
"com.unity.purchasing": "2.0.3",
"com.unity.textmeshpro": "1.2.4",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
......
......@@ -2,14 +2,18 @@
## Benötigte Programme
- Unity (für linux siehe unity-linux-editor-beta forum + MonoDevelop)
- Unity 2018.2 (für linux siehe unity-linux-editor-beta forum + MonoDevelop)
- git: https://git-scm.com/downloads
- git lfs: https://git-lfs.github.com/
## Installation
- Repository clonen
git lfs clone <git link> --recursive [ordner name]
### Git Hooks aktivieren
kopiere (post-checkout, post-merge und pre-commit) von "unity-git-hooks/scripts" nach ".git/hooks"
## OtherStuff ...
......
# 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. It can be configured using git config. Following example tells the
scripts that the assets directory is `client/Assets`.
```
git config unity3d.assets-dir client/Assets
```
#!/bin/bash
if ! [ -d ".git" ]; then
echo "Not in a git repository" >&2
exit 1
fi
SCRIPT_DIR=$(cd "${0%/*}" && pwd)
SCRIPTS=(pre-commit post-checkout post-merge)
for SCRIPT in "${SCRIPTS[@]}"; do
ln -snf "$SCRIPT_DIR/$SCRIPT" ".git/hooks/$SCRIPT"
done
echo "Installed ${SCRIPTS[*]}"
#!/bin/sh
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")"
# Remove empty assets directory
find "$ASSETS_DIR" -depth -type d -empty -delete
#!/bin/sh
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")"
# Remove empty assets directory
find "$ASSETS_DIR" -depth -type d -empty -delete
#!/bin/bash
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
ASSETS_DIR="$(git config --get unity3d.assets-dir || echo "Assets")"
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Redirect output to stderr.
exec 1>&2
git diff --cached --name-only --diff-filter=A -z $against -- "$ASSETS_DIR" | while read -d $'\0' f; do
ext="${f##*.}"
base="${f%.*}"
if [ "$ext" = "meta" ]; then
if [ $(git ls-files --cached -- "$base" | wc -l) = 0 ]; then
cat <<EOF
Error: Redudant meta file.
Meta file \`$f' is added, but \`$base' is not in the git index.
Please add \`$base' to git as well.
EOF
exit 1
fi
else
p="$f"
while [ "$p" != "$ASSETS_DIR" ]; do
if [ $(git ls-files --cached -- "$p.meta" | wc -l) = 0 ]; then
cat <<EOF
Error: Missing meta file.
Asset \`$f' is added, but \`$p.meta' is not in the git index.
Please add \`$p.meta' to git as well.
EOF
exit 1
fi
p="${p%/*}"
done
fi
done
ret="$?"
if [ "$ret" != 0 ]; then
exit "$ret"
fi
git diff --cached --name-only --diff-filter=D -z $against -- "$ASSETS_DIR" | while read -d $'\0' f; do
ext="${f##*.}"
base="${f%.*}"
if [ "$ext" = "meta" ]; then
if [ $(git ls-files --cached -- "$base" | wc -l) != 0 ]; then
cat <<EOF
Error: Redudant meta file.
Meta file \`$f' is removed, but \`$base' is still in the git index.
Please remove \`$base' from git as well.
EOF
exit 1
fi
else
p="$f"
while [ "$p" != "$ASSETS_DIR" ]; do
if [ $(git ls-files --cached -- "$p" | wc -l) = 0 ] && [ $(git ls-files --cached -- "$p.meta" | wc -l) != 0 ]; then
cat <<EOF
Error: Missing meta file.
Asset \`$f' is removed, but \`$p.meta' is still in the git index.
Please remove \`$p.meta' from git as well.
EOF
exit 1
fi
p="${p%/*}"
done
fi
done
ret="$?"
if [ "$ret" != 0 ]; then
exit "$ret"
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment