MCPcopy
hub / github.com/mislav/hub / transformFetchArgs

Function transformFetchArgs

commands/fetch.go:42–74  ·  view source on GitHub ↗
(args *Args)

Source from the content-addressed store, hash-verified

40}
41
42func transformFetchArgs(args *Args) error {
43 names := parseRemoteNames(args)
44
45 localRepo, err := github.LocalRepo()
46 utils.Check(err)
47
48 currentProject, currentProjectErr := localRepo.CurrentProject()
49
50 projects := make(map[*github.Project]bool)
51 ownerRegexp := regexp.MustCompile(fmt.Sprintf("^%s$", OwnerRe))
52 for _, name := range names {
53 if ownerRegexp.MatchString(name) && !isCloneable(name) {
54 _, err := localRepo.RemoteByName(name)
55 if err != nil {
56 utils.Check(currentProjectErr)
57 project := github.NewProject(name, currentProject.Name, "")
58 gh := github.NewClient(project.Host)
59 repo, err := gh.Repository(project)
60 if err != nil {
61 continue
62 }
63
64 projects[project] = repo.Private || repo.Permissions.Push
65 }
66 }
67 }
68
69 for project, private := range projects {
70 args.Before("git", "remote", "add", project.Owner, project.GitURL("", "", private))
71 }
72
73 return nil
74}
75
76func parseRemoteNames(args *Args) (names []string) {
77 words := args.Words()

Callers 1

fetchFunction · 0.85

Calls 11

RepositoryMethod · 0.95
GitURLMethod · 0.95
LocalRepoFunction · 0.92
CheckFunction · 0.92
NewProjectFunction · 0.92
NewClientFunction · 0.92
parseRemoteNamesFunction · 0.85
isCloneableFunction · 0.85
CurrentProjectMethod · 0.80
RemoteByNameMethod · 0.80
BeforeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…