Commit Diff


commit - 7bb16f79d9239b75da67f85f08d4a6586d7ecb14
commit + 8b635a9f0f8c22640d8e129df31a514deace0679
blob - 96163a5ec42083fb78cc5ad9f1a6d45b073c243d
blob + 81c60b38ef7c747d6edd8f051af60c9b0c442f7f
--- vc-got.el
+++ 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 
                   (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