mirror of
https://github.com/go-gitea/gitea
synced 2025-07-14 22:47:21 +00:00
Make git clone URL could use current signed-in user (#33091)
close #33086 * Add a special value for "SSH_USER" setting: `(DOER_USERNAME)` * Improve parseRepositoryURL and add tests (now it doesn't have hard dependency on some setting values) Many changes are just adding "ctx" and "doer" argument to functions. By the way, improve app.example.ini, remove all `%(key)s` syntax, it only makes messy and no user really cares about it. Document: https://gitea.com/gitea/docs/pulls/138
This commit is contained in:
@ -21,7 +21,7 @@ func (err ErrWrongURLFormat) Error() string {
|
||||
// GitURL represents a git URL
|
||||
type GitURL struct {
|
||||
*stdurl.URL
|
||||
extraMark int // 0 no extra 1 scp 2 file path with no prefix
|
||||
extraMark int // 0: standard URL with scheme, 1: scp short syntax (no scheme), 2: file path with no prefix
|
||||
}
|
||||
|
||||
// String returns the URL's string
|
||||
@ -38,8 +38,11 @@ func (u *GitURL) String() string {
|
||||
}
|
||||
}
|
||||
|
||||
// Parse parse all kinds of git URL
|
||||
func Parse(remote string) (*GitURL, error) {
|
||||
// ParseGitURL parse all kinds of git URL:
|
||||
// * Full URL: http://git@host/path, http://git@host:port/path
|
||||
// * SCP short syntax: git@host:/path
|
||||
// * File path: /dir/repo/path
|
||||
func ParseGitURL(remote string) (*GitURL, error) {
|
||||
if strings.Contains(remote, "://") {
|
||||
u, err := stdurl.Parse(remote)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user