Skip to content

Commit

Permalink
fix: Allow underscores in SourceHut usernames
Browse files Browse the repository at this point in the history
  • Loading branch information
twpayne committed Nov 19, 2022
1 parent 7acdf5b commit ca13b9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/initcmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ var dotfilesRepoGuesses = []struct {
sshRepoGuessRepl: "git@$2:$3/$4.git",
},
{
rx: regexp.MustCompile(`\Asr\.ht/~([-0-9A-Za-z]+)\z`),
rx: regexp.MustCompile(`\Asr\.ht/~([a-z_][a-z0-9_-]+)\z`),
httpRepoGuessRepl: "https://$1@git.sr.ht/~$1/dotfiles",
httpUsernameGuessRepl: "$1",
sshRepoGuessRepl: "git@git.sr.ht:~$1/dotfiles",
},
{
rx: regexp.MustCompile(`\Asr\.ht/~([-0-9A-Za-z]+)/([-0-9A-Za-z]+)\z`),
rx: regexp.MustCompile(`\Asr\.ht/~([a-z_][a-z0-9_-]+)/([-0-9A-Za-z]+)\z`),
httpRepoGuessRepl: "https://$1@git.sr.ht/~$1/$2",
httpUsernameGuessRepl: "$1",
sshRepoGuessRepl: "git@git.sr.ht:~$1/$2",
Expand Down
16 changes: 8 additions & 8 deletions pkg/cmd/initcmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ func TestGuessDotfilesRepoURL(t *testing.T) {
expectedSSHRepoURL: "git@gitlab.com:user/dots.git",
},
{
arg: "sr.ht/~user",
expectedHTTPRepoURL: "https://user@git.sr.ht/~user/dotfiles",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@git.sr.ht:~user/dotfiles",
arg: "sr.ht/~user_name",
expectedHTTPRepoURL: "https://user_name@git.sr.ht/~user_name/dotfiles",
expectedHTTPUsername: "user_name",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dotfiles",
},
{
arg: "sr.ht/~user/dots",
expectedHTTPRepoURL: "https://user@git.sr.ht/~user/dots",
expectedHTTPUsername: "user",
expectedSSHRepoURL: "git@git.sr.ht:~user/dots",
arg: "sr.ht/~user_name/dots",
expectedHTTPRepoURL: "https://user_name@git.sr.ht/~user_name/dots",
expectedHTTPUsername: "user_name",
expectedSSHRepoURL: "git@git.sr.ht:~user_name/dots",
},
{
arg: "user",
Expand Down

0 comments on commit ca13b9d

Please sign in to comment.