Skip to content

Commit

Permalink
Add support for GoogleSource
Browse files Browse the repository at this point in the history
  • Loading branch information
modulitos committed Jan 15, 2023
1 parent 4df4e14 commit 026ca66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -82,6 +82,7 @@ Name of the remote branch to link to.
* [GitHub](http://github.com)
* [GitLab](https://gitlab.com)
* [Gitorious](http://gitorious.org)
* [GoogleSource](https://googlesource.com)
* [Savannah](https://git.savannah.gnu.org/cgit)
* [Sourcegraph](https://sourcegraph.com)
* [sourcehut](https://sourcehut.org)
Expand Down
5 changes: 4 additions & 1 deletion git-link-test.el
Expand Up @@ -62,4 +62,7 @@
(git-link--parse-remote "git://git.savannah.gnu.org/emacs.git")))

(should (equal '("us-west-2.console.aws.amazon.com" "codesuite/codecommit/repositories/TestRepo")
(git-link--parse-remote "ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/TestRepo"))))
(git-link--parse-remote "ssh://git-codecommit.us-west-2.amazonaws.com/v1/repos/TestRepo")))

(should (equal '("go.googlesource.com" "go")
(git-link--parse-remote "https://go.googlesource.com/go"))))
19 changes: 19 additions & 0 deletions git-link.el
Expand Up @@ -214,6 +214,7 @@ See its docs."
("gitorious" git-link-gitorious)
("gitlab" git-link-gitlab)
("git\\.\\(sv\\|savannah\\)\\.gnu\\.org" git-link-savannah)
("googlesource.com" git-link-googlesource)
("visualstudio\\|azure" git-link-azure)
("sourcegraph" git-link-sourcegraph)
("\\(amazonaws\\|amazon\\)\\.com" git-link-codecommit))
Expand All @@ -235,6 +236,7 @@ As an example, \"gitlab\" will match with both \"gitlab.com\" and
("gitorious" git-link-commit-gitorious)
("gitlab" git-link-commit-github)
("git\\.\\(sv\\|savannah\\)\\.gnu\\.org" git-link-commit-savannah)
("googlesource.com" git-link-commit-googlesource)
("visualstudio\\|azure" git-link-commit-azure)
("sourcegraph" git-link-commit-sourcegraph)
("\\(amazonaws\\|amazon\\)\\.com" git-link-commit-codecommit))
Expand All @@ -255,6 +257,7 @@ As an example, \"gitlab\" will match with both \"gitlab.com\" and
("gitorious" git-link-homepage-github)
("gitlab" git-link-homepage-github)
("git\\.\\(sv\\|savannah\\)\\.gnu\\.org" git-link-homepage-savannah)
("googlesource.com" git-link-homepage-github)
("visualstudio\\|azure" git-link-homepage-github)
("sourcegraph" git-link-homepage-github)
("\\(amazonaws\\|amazon\\)\\.com" git-link-homepage-codecommit))
Expand Down Expand Up @@ -549,6 +552,16 @@ return (FILENAME . REVISION) otherwise nil."
(format "L%s-L%s" start end)
(format "L%s" start)))))))

(defun git-link-googlesource (hostname dirname filename branch commit start end)
(format "https://%s/%s/+/%s/%s"
hostname
dirname
(or branch commit)
(concat filename
(when start
(format "#%s" start)
))))

(defun git-link-azure (hostname dirname filename branch commit start end)
(format "https://%s/%s?path=%%2F%s&version=%s&line=%s&lineEnd=%s&lineStartColumn=1&lineEndColumn=9999&lineStyle=plain"
hostname
Expand Down Expand Up @@ -577,6 +590,12 @@ return (FILENAME . REVISION) otherwise nil."
dirname
commit))

(defun git-link-commit-googlesource (hostname dirname commit)
(format "https://%s/%s/+/%s"
hostname
dirname
commit))

(defun git-link-commit-azure (hostname dirname commit)
(format "https://%s/%s/commit/%s"
hostname
Expand Down

0 comments on commit 026ca66

Please sign in to comment.