This repository has been archived by the owner on Mar 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from dwyl/update-docs-issue-#1
Update docs issue #1
- Loading branch information
Showing
9 changed files
with
33 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "test-repo"] | ||
path = test-repo | ||
url = https://gitea-server.fly.dev/nelsonic/public-repo.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,21 +23,18 @@ defmodule Gitea.Helpers do | |
end | ||
|
||
@doc """ | ||
`make_url/2` constructs the URL based on the supplied git `url` and TCP `port`. | ||
If the `port` is set it will be a custom Gitea instance. | ||
`make_url/1` constructs the URL based on the supplied git `url`. | ||
## Examples | ||
iex> Gitea.Helpers.make_url("gitea-server.fly.dev", "10022") | ||
"ssh://[email protected]:10022/" | ||
iex> Gitea.Helpers.make_url("gitea-server.fly.dev") | ||
"[email protected]:" | ||
iex> Gitea.Helpers.make_url("github.com") | ||
"[email protected]:" | ||
""" | ||
@spec make_url(String.t(), integer() | nil) :: String.t() | ||
def make_url(git_url, port \\ 0) | ||
def make_url(git_url, port) when port > 0, do: "ssh://git@#{git_url}:#{port}/" | ||
def make_url(git_url, _port), do: "git@#{git_url}:" | ||
@spec make_url(String.t()) :: String.t() | ||
def make_url(git_url), do: "git@#{git_url}:" | ||
|
||
@doc """ | ||
`remote_url/3` returns the git remote url. | ||
|
@@ -53,8 +50,7 @@ defmodule Gitea.Helpers do | |
@spec remote_url_ssh(String.t(), String.t()) :: String.t() | ||
def remote_url_ssh(org, repo) do | ||
url = Envar.get("GITEA_URL") | ||
port = Envar.get("GITEA_SSH_PORT", nil) | ||
git_url = Gitea.Helpers.make_url(url, port) | ||
git_url = make_url(url) | ||
remote_url(git_url, org, repo) | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
text test-repo50098413206073914 | ||
text test-repo9225876994531516 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,13 @@ defmodule Gitea.HelpersTest do | |
end | ||
|
||
test "make_url/2 returns a valid gitea (Fly.io) Base URL" do | ||
git_url = Gitea.Helpers.make_url("gitea-server.fly.dev", "10022") | ||
assert git_url == "ssh://[email protected]:10022/" | ||
git_url = Gitea.Helpers.make_url("gitea-server.fly.dev") | ||
assert git_url == "[email protected]:" | ||
end | ||
|
||
test "remote_url/3 returns a valid gitea (Fly.io) remote URL" do | ||
git_url = Gitea.Helpers.make_url("gitea-server.fly.dev", "10022") | ||
git_url = Gitea.Helpers.make_url("gitea-server.fly.dev") | ||
remote_url = Gitea.Helpers.remote_url(git_url, "nelsonic", "public-repo") | ||
assert remote_url == "ssh://[email protected]:10022/nelsonic/public-repo.git" | ||
assert remote_url == "[email protected]:nelsonic/public-repo.git" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
text test-repo38958817237599362 |