MCPcopy Create free account
hub / github.com/dagger/dagger / IsRemotePublic

Function IsRemotePublic

core/schema/git.go:782–801  ·  view source on GitHub ↗
(ctx context.Context, remote *gitutil.GitURL)

Source from the content-addressed store, hash-verified

780}
781
782func IsRemotePublic(ctx context.Context, remote *gitutil.GitURL) (bool, error) {
783 // check if repo is public
784 repo := git.NewRemote(memory.NewStorage(), &config.RemoteConfig{
785 Name: "origin",
786 URLs: []string{remote.Remote()},
787 })
788 _, err := repo.ListContext(ctx, &git.ListOptions{Auth: nil})
789 if err != nil {
790 // Some Git hosts (Azure Repos and custom portals) return a 200 HTML login page for unauthenticated refs: go-git reports ErrInvalidPktLen
791 // treat as auth-required/private
792 if errors.Is(err, pktline.ErrInvalidPktLen) {
793 return false, nil
794 }
795 if errors.Is(err, transport.ErrAuthenticationRequired) {
796 return false, nil
797 }
798 return false, err
799 }
800 return true, nil
801}
802
803type refArgs struct {
804 Name string

Callers 2

TestIsRemotePublicMethod · 0.92
gitMethod · 0.85

Calls 2

IsMethod · 0.80
RemoteMethod · 0.65

Tested by 1

TestIsRemotePublicMethod · 0.74