aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--emacs/README.org6
-rw-r--r--emacs/init.html4
-rwxr-xr-xemacs/pre-push81
3 files changed, 89 insertions, 2 deletions
diff --git a/emacs/README.org b/emacs/README.org
index ff155ce..a4b99f8 100644
--- a/emacs/README.org
+++ b/emacs/README.org
@@ -37,6 +37,12 @@ go get -u github.com/dougm/goflymake
go get -u github.com/nsf/gocode
#+END_SRC
+** Developing
+
+I've added a git =pre-push= hook which syncs the =init.html= and the =org.css=
+files into my personal server. So make sure to add this hook into the
+=.git/hooks= directory.
+
** Installing
The installation process of my GNU Emacs configuration should already be handled
diff --git a/emacs/init.html b/emacs/init.html
index c4c85c2..db009d5 100644
--- a/emacs/init.html
+++ b/emacs/init.html
@@ -4,7 +4,7 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>mssola's GNU Emacs configuration</title>
-<!-- 2017-01-25 Wed 17:40 -->
+<!-- 2017-01-26 Thu 11:05 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="generator" content="Org-mode" />
<meta name="author" content="Miquel Sabaté Solà" />
@@ -2285,7 +2285,7 @@ along with this program. If not, see <a href="http://www.gnu.org/licenses/">&lt
</div>
<div id="postamble" class="status">
<p class="author">Author: Miquel Sabaté Solà</p>
-<p class="date">Created: 2017-01-25 Wed 17:40</p>
+<p class="date">Created: 2017-01-26 Thu 11:05</p>
<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 25.1.1 (<a href="http://orgmode.org">Org</a> mode 8.2.10)</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
diff --git a/emacs/pre-push b/emacs/pre-push
new file mode 100755
index 0000000..ec6b3ec
--- /dev/null
+++ b/emacs/pre-push
@@ -0,0 +1,81 @@
+#!/bin/sh
+# Copyright (C) 2017 Miquel Sabaté Solà <mikisabate@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Most of the code is taken from the default pre-push.sample file.
+
+# From the documentation, if the foreign ref does not yet exist the
+# <remote SHA1> will be 40 0.
+z40=0000000000000000000000000000000000000000
+
+# The path where the files are to be stored on the server.
+__mssola_remote_path=/home/mssola/static
+
+# Safely join paths.
+__mssola_join_path() {
+ local IFS="/"; echo "$*";
+}
+
+# This function does the actual syncing. It takes one argument, which is the
+# file to be synced. Note that this function assumes that the given file is
+# under the "emacs" directory.
+__mssola_sync_cheato() {
+ path=$(realpath .)
+
+ src=$(__mssola_join_path $path "emacs" $1)
+ dst=$(__mssola_join_path "cheato.mssola.com:$__mssola_remote_path" $1)
+
+ echo "Syncing $(__mssola_join_path emacs $1)"
+ rsync $src $dst
+}
+
+# Copy the files that I want to my server.
+__mssola_sync() {
+ __mssola_sync_cheato "init.html"
+ __mssola_sync_cheato "org.css"
+}
+
+# This block iterates through all the given info provided by git. If there is
+# a change on a GNU Emacs file, then it needs to by synced with my server.
+while read local_ref local_sha remote_ref remote_sha
+do
+ echo "LOOP"
+ if [ "$local_sha" = $z40 ]
+ then
+ # Handle delete
+ :
+ else
+ if [ "$remote_sha" = $z40 ]
+ then
+ # New branch, examine all commits
+ range="$local_sha"
+ else
+ # Update to existing branch, examine new commits
+ range="$remote_sha..$local_sha"
+ fi
+
+ # Commits afecting GNU Emacs are prefixed with "emacs: ". It's a
+ # convention that I always follow.
+ commit=`git rev-list -n 1 --grep '^emacs:' "$range"`
+ echo "COMMIT $commit"
+ if [ -n "$commit" ]
+ then
+ __mssola_sync
+ exit 0
+ fi
+ fi
+done
+
+exit 0