branch: externals/vc-got
commit 8b635a9f0f8c22640d8e129df31a514deace0679
Author: Omar Polo <[email protected]>
Commit: Omar Polo <[email protected]>
implement repository-url
---
vc-got.el | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/vc-got.el b/vc-got.el
index 96163a5..81c60b3 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -107,7 +107,7 @@
;; - extra-menu NOT IMPLEMENTED
;; - extra-dir-menu NOT IMPLEMENTED
;; - conflicted-files DONE
-;; - repository-url NOT IMPLEMENTED
+;; - repository-url DONE
;; TODO: use the idiom
;; (let (process-file-side-effects) ...)
@@ -630,5 +630,22 @@ Value is returned as floating point fractional number of
days."
(push file conflicts))
finally return conflicts)))
+(defun vc-got-repository-url (_file &optional remote-name)
+ "Return URL for REMOTE-NAME, or for \"origin\" if nil."
+ (let* ((default-directory (vc-got--repo-root))
+ (remote-name (or remote-name "origin"))
+ (heading (concat "[remote \"" remote-name "\"]"))
+ found)
+ (with-temp-buffer
+ (insert-file-contents "config")
+ (goto-char (point-min))
+ (when (search-forward heading nil t)
+ (forward-line)
+ (while (and (not found)
+ (looking-at ".*=")) ;too broad?
+ (when (looking-at ".*url = \\(.*\\)")
+ (setq found (match-string-no-properties 1))))
+ found))))
+
(provide 'vc-got)
;;; vc-got.el ends here