Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 73 lines (61 sloc) 2.541 kB
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
1 ;;; hyde-git.el
2 ;; Copyright (C) 2004 Noufal Ibrahim <noufal at nibrahim.net.in>
3 ;;
4 ;; This program is not part of Gnu Emacs
5 ;;
274a70f @nibrahim Bumps LICENSE to GPLv3 and adds LICENSE and CHANGELOG files
nibrahim authored
6 ;; hyde-git.el is free software; you can redistribute it and/or modify
7 ;; it under the terms of the GNU General Public License as published
8 ;; by the Free Software Foundation; either version 3 of the License,
9 ;; or (at your option) any later version.
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
10 ;;
11 ;; This program is distributed in the hope that it will be useful, but
12 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 ;; General Public License for more details.
15 ;;
16 ;; You should have received a copy of the GNU General Public License
17 ;; along with this program; if not, write to the Free Software
18 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 ;; 02111-1307, USA.
20
88fbfeb @nibrahim Allow remote and remote branch to be configurable
nibrahim authored
21 (defcustom hyde/git/remote
22 "origin"
23 "The remote which should be pushed to"
24 :group 'hyde)
25
26 (defcustom hyde/git/remote-branch
27 "master"
28 "The name of the branch on the remote which should be pushed to"
29 :group 'hyde)
30
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
31 (defun hyde/git/uncommittedp (repo file)
32 "Returns true if there are uncommitted changes for the current file"
33 (let (
9af5e19 @nibrahim Posts are drafts by default now and will be promoted only upon request
nibrahim authored
34 (cmd (format "cd '%s' && git diff-files --quiet '%s' > /dev/null" repo file))
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
35 )
36 (= (shell-command cmd) 1)))
37
38 (defun hyde/git/unpushedp (repo file)
39 "Returns true if there are unpushed changes for the current file"
40 (let (
88fbfeb @nibrahim Allow remote and remote branch to be configurable
nibrahim authored
41 (cmd
42 (format "cd '%s' && git log --exit-code %s/%s..HEAD '%s' > /dev/null" repo hyde/git/remote hyde/git/remote-branch file)
43 ))
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
44 (= (shell-command cmd) 1)))
45
46 (defun hyde/git/pushedp (repo file)
47 "Returns true if there are no uncommitted changes in the file"
48 (not (hyde/git/uncommittedp repo file)))
49
407bea1 @nibrahim Implemeted commit, generate and deploy
nibrahim authored
50 (defun hyde/git/add (repo file)
51 "Adds the given file to the repository"
9af5e19 @nibrahim Posts are drafts by default now and will be promoted only upon request
nibrahim authored
52 (let ((cmd (format "cd '%s' && git add '%s' > /dev/null" repo file)))
407bea1 @nibrahim Implemeted commit, generate and deploy
nibrahim authored
53 (shell-command cmd)))
54
55 (defun hyde/git/commit (repo file commit-message)
56 "Commits the given file to the repository"
9af5e19 @nibrahim Posts are drafts by default now and will be promoted only upon request
nibrahim authored
57 (let ((cmd (format "cd '%s' && git commit -m '%s' '%s' > /dev/null" repo commit-message file)))
407bea1 @nibrahim Implemeted commit, generate and deploy
nibrahim authored
58 (shell-command cmd)))
59
60 (defun hyde/git/push (repo)
61 "Pushes the repository"
88fbfeb @nibrahim Allow remote and remote branch to be configurable
nibrahim authored
62 (let ((cmd (format "cd '%s' && git push %s %s > /dev/null" repo hyde/git/remote hyde/git/remote-branch)))
181f9d2 @nibrahim Made hyde-home buffer local to handle multiple blogs and fixed new bugs
nibrahim authored
63 (message cmd)
407bea1 @nibrahim Implemeted commit, generate and deploy
nibrahim authored
64 (shell-command cmd)))
65
9af5e19 @nibrahim Posts are drafts by default now and will be promoted only upon request
nibrahim authored
66 (defun hyde/git/rename (base from to)
67 "Rename the file in BASE from FROM to TO"
68 (let ((cmd (format "cd '%s' && git mv '%s' '%s' > /dev/null" base from to)))
69 (shell-command cmd)))
407bea1 @nibrahim Implemeted commit, generate and deploy
nibrahim authored
70
71
ee0a681 @nibrahim Basic commands to get statuses of posts working
nibrahim authored
72 (provide 'hyde-git)
Something went wrong with that request. Please try again.