Add base for detached run task; remove task usage and replace with project and classi...
[SquirrelJME.git] / utils-dev / storenotes.sh
blob74875a7aeb6e4901796fa29c0995cbb98a37c190
1 #!/bin/sh
2 # ---------------------------------------------------------------------------
3 # Multi-Phasic Applications: SquirrelJME
4 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 # Copyright (C) Multi-Phasic Applications <multiphasicapps.net>
6 # ---------------------------------------------------------------------------
7 # SquirrelJME is under the GNU General Public License v3+, or later.
8 # See license.mkd for licensing and copyright information.
9 # ---------------------------------------------------------------------------
10 # DESCRIPTION: Extracts notes from the unversioned space and stores them in
11 # the repository for backup purposes.
13 # Force C locale
14 export LC_ALL=C
16 # Directory of this script
17 __exedir="$(dirname -- "$0")"
19 # Go through all unversioned files for the blog
20 __changed=0
21 fossil uv ls | grep '^developer-notes\/' | while read __line
23 # Target directory
24 __target="$__exedir/../assets/$__line"
25 __tardir="$(dirname -- "$__target")"
27 # Calculate the sums of both files
28 __isum="$(fossil uv cat "$__line" | fossil sha1sum - |
29 tr '\t' ' ' | cut -d ' ' -f 1)"
30 __xsum="$(if [ -f "$__target" ];
31 then cat "$__target" | fossil sha1sum - | tr '\t' ' ' | cut -d ' ' -f 1;
32 else echo "0"; fi)"
34 # Debug
35 echo "$__line -> $__target ($__tardir) [$__isum $__xsum]"
37 # If the sums differ then overwrite the destination files
38 if [ "$__isum" != "$__xsum" ]
39 then
40 # Make the target directory
41 if [ ! -d "$__tardir" ]
42 then
43 mkdir -p "$__tardir"
46 # Extract and add it
47 fossil uv cat "$__line" > "$__target"
48 fossil add "$__target"
50 # Increase change count
51 __changed="$(($__changed + 1))"
53 done
55 # Files changed?
56 #if [ "$__changed" -gt "0" ]
57 #then
58 fossil commit --no-prompt -m "Backup developer notes."
59 #fi
61 # Clear temporary
62 rm -f "/tmp/$$"