Merge pull request #4588 from cli/bin-ext-migrate
binary extension migration
This commit is contained in:
commit
b5d90e1204
4 changed files with 147 additions and 9 deletions
|
|
@ -84,6 +84,15 @@ func CurrentBranch() (string, error) {
|
|||
return "", fmt.Errorf("%sgit: %s", stderr.String(), err)
|
||||
}
|
||||
|
||||
func listRemotesForPath(path string) ([]string, error) {
|
||||
remoteCmd, err := GitCommand("-C", path, "remote", "-v")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
output, err := run.PrepareCmd(remoteCmd).Output()
|
||||
return outputLines(output), err
|
||||
}
|
||||
|
||||
func listRemotes() ([]string, error) {
|
||||
remoteCmd, err := GitCommand("remote", "-v")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -35,16 +35,11 @@ func (r *Remote) String() string {
|
|||
return r.Name
|
||||
}
|
||||
|
||||
// Remotes gets the git remotes set for the current repo
|
||||
func Remotes() (RemoteSet, error) {
|
||||
list, err := listRemotes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
remotes := parseRemotes(list)
|
||||
func remotes(path string, remoteList []string) (RemoteSet, error) {
|
||||
remotes := parseRemotes(remoteList)
|
||||
|
||||
// this is affected by SetRemoteResolution
|
||||
remoteCmd, err := GitCommand("config", "--get-regexp", `^remote\..*\.gh-resolved$`)
|
||||
remoteCmd, err := GitCommand("-C", path, "config", "--get-regexp", `^remote\..*\.gh-resolved$`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -70,6 +65,23 @@ func Remotes() (RemoteSet, error) {
|
|||
return remotes, nil
|
||||
}
|
||||
|
||||
func RemotesForPath(path string) (RemoteSet, error) {
|
||||
list, err := listRemotesForPath(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return remotes(path, list)
|
||||
}
|
||||
|
||||
// Remotes gets the git remotes set for the current repo
|
||||
func Remotes() (RemoteSet, error) {
|
||||
list, err := listRemotes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return remotes(".", list)
|
||||
}
|
||||
|
||||
func parseRemotes(gitRemotes []string) (remotes RemoteSet) {
|
||||
for _, r := range gitRemotes {
|
||||
match := remoteRE.FindStringSubmatch(r)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue