| 1 | #! /usr/bin/env bash |
| 2 | |
| 3 | # GNU AGPLv3 (or later at your option) |
| 4 | # see bottom for more license info. |
| 5 | # please keep this notice. |
| 6 | # This file is part of coding-replay. |
| 7 | |
| 8 | set -o nounset |
| 9 | set -o errexit |
| 10 | |
| 11 | project="$(basename "$(pwd)")" |
| 12 | |
| 13 | while sleep 1; do |
| 14 | if ! git diff-index --quiet HEAD --\ |
| 15 | || \ |
| 16 | ! git ls-files --other --directory --exclude-standard | sed q1; |
| 17 | then |
| 18 | datetime=$(date -u '+%Y-%m-%d-%H-%M-%S.%N') |
| 19 | uuid=$(uuid -v4) |
| 20 | temp_project_dir="${project}-${datetime}-${uuid}" |
| 21 | cd .. || exit 1 # in case cd fails |
| 22 | cp -r "${project}" "${temp_project_dir}" |
| 23 | cd "${temp_project_dir}" || exit 1 # in case cd fails |
| 24 | if make test; then |
| 25 | cd "../${project}" || exit 1 # in case cd fails |
| 26 | git add . |
| 27 | git commit -am "${uuid} |
| 28 | |
| 29 | ${datetime}" |
| 30 | fi |
| 31 | cd .. || exit 1 # in case cd fails |
| 32 | rm -rf "${temp_project_dir}" |
| 33 | cd "${project}" || exit 1 # in case cd fails |
| 34 | fi |
| 35 | done |
| 36 | |
| 37 | # coding-replay is free software: you can redistribute it and/or modify it |
| 38 | # under the terms of the GNU Affero General Public License as published |
| 39 | # by the Free Software Foundation, either version 3 of the License, or |
| 40 | # (at your option) any later version. |
| 41 | |
| 42 | # coding-replay is distributed in the hope that it will be useful, but |
| 43 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
| 44 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 45 | # GNU Affero General Public License for more details. |
| 46 | |
| 47 | # You should have received a copy of the GNU Affero General Public |
| 48 | # License along with coding-replay. If not, see |
| 49 | # <http://www.gnu.org/licenses/>. |