summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.junit.http/BUCK
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2021-11-24 17:54:51 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2021-11-24 17:54:51 +0100
commitad8d89b9c095e37bdf9b48dab0b71f9efc7a1d77 (patch)
treee950c020facf6eb9cfc10bb10d1f5a624e4ef715 /org.eclipse.jgit.junit.http/BUCK
parent751e3ad5d1f67018421d53e3ae03444ff6f5d840 (diff)
downloadjgit-6.0.0.202111241155-rc1.tar.gz
jgit-6.0.0.202111241155-rc1.zip
JGit v6.0.0.202111241155-rc1v6.0.0.202111241155-rc1
Change-Id: I35dc089a00ee12f83f506fb320d23762fa030063 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit.http/BUCK')
0 files changed, 0 insertions, 0 deletions
teral.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// Copyright 2021 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.

package git

import (
	"context"
	"net/url"
)

// GetRemoteAddress returns the url of a specific remote of the repository.
func GetRemoteAddress(ctx context.Context, repoPath, remoteName string) (*url.URL, error) {
	err := LoadGitVersion()
	if err != nil {
		return nil, err
	}
	var cmd *Command
	if CheckGitVersionAtLeast("2.7") == nil {
		cmd = NewCommand(ctx, "remote", "get-url", remoteName)
	} else {
		cmd = NewCommand(ctx, "config", "--get", "remote."+remoteName+".url")
	}

	result, _, err := cmd.RunStdString(&RunOpts{Dir: repoPath})
	if err != nil {
		return nil, err
	}

	if len(result) > 0 {
		result = result[:len(result)-1]
	}
	return url.Parse(result)
}