Commit
+46 -13 +/-3 browse
1 | diff --git a/contrib/note-on-modification b/contrib/note-on-modification |
2 | new file mode 100755 |
3 | index 0000000..8f3a326 |
4 | --- /dev/null |
5 | +++ b/contrib/note-on-modification |
6 | @@ -0,0 +1,16 @@ |
7 | + #!/bin/bash |
8 | + # This is an example script that can be used in conjunction with the |
9 | + # on_modification config option to commit every note change to a git |
10 | + # repository. You'll need to place it somewhere on your $PATH. This |
11 | + # script assumes that your state_dir is also a git repository. |
12 | + set -e |
13 | + |
14 | + COMMIT_MESSAGE="automated commit ($HOSTNAME)" |
15 | + |
16 | + STATE_DIR="$(note config get state_dir)" |
17 | + GIT_DIR="$STATE_DIR/.git" |
18 | + WORK_DIR="$STATE_DIR" |
19 | + GIT="git --git-dir=$GIT_DIR --work-tree=$WORK_DIR" |
20 | + |
21 | + $GIT add --all |
22 | + $GIT commit -m "$COMMIT_MESSAGE" |
23 | diff --git a/contrib/note-on-sync b/contrib/note-on-sync |
24 | new file mode 100755 |
25 | index 0000000..7cc174d |
26 | --- /dev/null |
27 | +++ b/contrib/note-on-sync |
28 | @@ -0,0 +1,30 @@ |
29 | + #!/bin/bash |
30 | + # This is an example script that will synchronize a git repository that is |
31 | + # presumed to be the state_dir of a note directory. It will initially check |
32 | + # to see if changes exist remotely and try to rebase them onto the current |
33 | + # HEAD. |
34 | + set -e |
35 | + |
36 | + REMOTE="origin" |
37 | + |
38 | + |
39 | + STATE_DIR="$(note config get state_dir)" |
40 | + GIT_DIR="$STATE_DIR/.git" |
41 | + WORK_DIR="$STATE_DIR" |
42 | + GIT="git --git-dir=$GIT_DIR --work-tree=$WORK_DIR" |
43 | + |
44 | + # assume the current branch is desired |
45 | + BRANCH="$($GIT branch --show-current)" |
46 | + |
47 | + $GIT fetch --quiet --all |
48 | + |
49 | + LOCAL_HEAD="$($GIT rev-parse @)" |
50 | + REMOTE_HEAD="$($GIT rev-parse $REMOTE/$BRANCH)" |
51 | + |
52 | + # check if remote and local head are out of sync, if they are then pull down |
53 | + # changes with --rebase --interactive |
54 | + if [[ "$LOCAL_HEAD" != "$REMOTE_HEAD" ]] ; then |
55 | + $GIT pull --quiet --ff-only "$REMOTE" "$BRANCH" |
56 | + fi |
57 | + |
58 | + $GIT push --quiet "$REMOTE" "$BRANCH" |
59 | diff --git a/contrib/note_commit.sh b/contrib/note_commit.sh |
60 | deleted file mode 100755 |
61 | index 140ba30..0000000 |
62 | --- a/contrib/note_commit.sh |
63 | +++ /dev/null |
64 | @@ -1,13 +0,0 @@ |
65 | - #!/bin/bash |
66 | - # This is an example script that can be used in conjunction with the |
67 | - # on_modification config option to commit every note change to a git |
68 | - # repository. You'll need to place it somewhere on your $PATH. This |
69 | - # script assumes that your state_dir is also a git repository. |
70 | - set -e |
71 | - |
72 | - STATE_DIR="$(note config get state_dir)" |
73 | - |
74 | - pushd "$STATE_DIR" |
75 | - git add --all |
76 | - git commit -m 'automated commit' |
77 | - popd |