Skip to content

Commit 183087e

Browse files
committed
Avoid grep and awk
1 parent e6b9180 commit 183087e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/koga/pin.lisp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
(in-package #:koga)
22

3+
(defvar +head-branch-text+ "HEAD branch: ")
4+
35
(defun pin-repo (pinp &key name extension directory repository branch commit freeze)
46
(when (and (not branch)
57
(probe-file directory))
6-
(setf branch (run-program-capture "git remote show origin | grep 'HEAD branch' | awk '{print $NF}'" :directory directory)))
8+
(let* ((output (run-program-capture "git remote show origin" :directory directory))
9+
(pos (search +head-branch-text+ output)))
10+
(when pos
11+
(setf branch (subseq output
12+
(+ pos (length +head-branch-text+))
13+
(position #\newline output :start pos))))))
714
(loop for (key value) on `(:name ,name
815
:extension ,extension
916
:directory ,directory

0 commit comments

Comments
 (0)