Browse files

Expands directory names

Expands all all arguments to cd in various git commands using expand-file-name so
that things like ~, . and .. work as expected. Fixes #4. Fixes #8
  • Loading branch information...
1 parent 2f9812f commit f711ae11f6d305754f2f6061df2764826b81b0cb @nibrahim committed Sep 22, 2012
Showing with 10 additions and 10 deletions.
  1. +7 −7 hyde-git.el
  2. +3 −3 hyde.el
View
14 hyde-git.el
@@ -31,15 +31,16 @@
(defun hyde/git/uncommittedp (repo file)
"Returns true if there are uncommitted changes for the current file"
(let (
- (cmd (format "cd '%s' && git diff-files --quiet '%s' > /dev/null" repo file))
+ (cmd (format "cd '%s' && git diff-files --quiet '%s' > /dev/null" (expand-file-name repo) file))
)
(= (shell-command cmd) 1)))
+
(defun hyde/git/unpushedp (repo file)
"Returns true if there are unpushed changes for the current file"
(let (
(cmd
- (format "cd '%s' && git log --exit-code %s/%s..HEAD '%s' > /dev/null" repo hyde/git/remote hyde/git/remote-branch file)
+ (format "cd '%s' && git log --exit-code %s/%s..HEAD '%s' > /dev/null" (expand-file-name repo) hyde/git/remote hyde/git/remote-branch file)
))
(= (shell-command cmd) 1)))
@@ -49,24 +50,23 @@
(defun hyde/git/add (repo file)
"Adds the given file to the repository"
- (let ((cmd (format "cd '%s' && git add '%s' > /dev/null" repo file)))
+ (let ((cmd (format "cd '%s' && git add '%s' > /dev/null" (expand-file-name repo) file)))
(shell-command cmd)))
(defun hyde/git/commit (repo file commit-message)
"Commits the given file to the repository"
- (let ((cmd (format "cd '%s' && git commit -m '%s' '%s' > /dev/null" repo commit-message file)))
+ (let ((cmd (format "cd '%s' && git commit -m '%s' '%s' > /dev/null" (expand-file-name repo) commit-message file)))
(shell-command cmd)))
(defun hyde/git/push (repo)
"Pushes the repository"
- (let ((cmd (format "cd '%s' && git push %s %s > /dev/null" repo hyde/git/remote hyde/git/remote-branch)))
+ (let ((cmd (format "cd '%s' && git push %s %s > /dev/null" (expand-file-name repo) hyde/git/remote hyde/git/remote-branch)))
(message cmd)
(shell-command cmd)))
(defun hyde/git/rename (base from to)
"Rename the file in BASE from FROM to TO"
- (let ((cmd (format "cd '%s' && git mv '%s' '%s' > /dev/null" base from to)))
+ (let ((cmd (format "cd '%s' && git mv '%s' '%s' > /dev/null" (expand-file-name base) from to)))
(shell-command cmd)))
-
(provide 'hyde-git)
View
6 hyde.el
@@ -183,12 +183,12 @@
(defun hyde/run-jekyll ()
"Runs jekyll on the directory"
(interactive)
- (shell-command (format "cd %s && %s" hyde-home hyde/jekyll-command)))
+ (shell-command (format "cd %s && %s" (expand-file-name hyde-home) hyde/jekyll-command)))
(defun hyde/deploy ()
"Deploys the generated website (should be run after hyde/run-jekyll"
(interactive)
- (shell-command (format "cd %s && %s" hyde-home hyde/deploy-command)))
+ (shell-command (format "cd %s && %s" (expand-file-name hyde-home) hyde/deploy-command)))
;; Utility functions
@@ -231,7 +231,7 @@ properly and returns them so that they can be presented to the
user"
(let (
(posts (split-string (strip-string (shell-command-to-string
- (concat "cd " hyde-home "/" dir " ; " hyde/hyde-list-posts-command ))))))
+ (concat "cd " (expand-file-name hyde-home) "/" dir " ; " hyde/hyde-list-posts-command ))))))
(map 'list (lambda (f) (format "%s : %s" (hyde/file-status dir f) f)) posts)))
(defun hyde/promote-to-post (pos)

0 comments on commit f711ae1

Please sign in to comment.