Structs
            
            
               
                  Origin
                  struct
                  #
               
               
               An Origin describes the provenance of a given repo method result.
It can be passed to CheckReuse (usually in a different go command invocation)
to see whether the result remains up-to-date.
               
               type Origin struct {
VCS string `json:",omitempty"`
URL string `json:",omitempty"`
Subdir string `json:",omitempty"`
Hash string `json:",omitempty"`
TagPrefix string `json:",omitempty"`
TagSum string `json:",omitempty"`
Ref string `json:",omitempty"`
RepoSum string `json:",omitempty"`
}
            
            
            
               
                  RevInfo
                  struct
                  #
               
               
               A RevInfo describes a single revision in a source code repository.
               
               type RevInfo struct {
Origin *Origin
Name string
Short string
Version string
Time time.Time
Tags []string
}
            
            
            
               
                  RunArgs
                  struct
                  #
               
               
               type RunArgs struct {
cmdline []any
dir string
local bool
env []string
stdin io.Reader
}
            
            
            
               
                  RunError
                  struct
                  #
               
               
               type RunError struct {
Cmd string
Err error
Stderr []byte
HelpText string
}
            
            
            
               
                  Tag
                  struct
                  #
               
               
               A Tag describes a single tag in a code repository.
               
               type Tag struct {
Name string
Hash string
}
            
            
            
               
                  Tags
                  struct
                  #
               
               
               A Tags describes the available tags in a code repository.
               
               type Tags struct {
Origin *Origin
List []Tag
}
            
            
            
               
                  UnknownRevisionError
                  struct
                  #
               
               
               UnknownRevisionError is an error equivalent to fs.ErrNotExist, but for a
revision rather than a file.
               
               type UnknownRevisionError struct {
Rev string
}
            
            
            
               
                  VCSError
                  struct
                  #
               
               
               A VCSError indicates an error using a version control system.
The implication of a VCSError is that we know definitively where
to get the code, but we can't access it due to the error.
The caller should report this error instead of continuing to probe
other possible module paths.
TODO(golang.org/issue/31730): See if we can invert this. (Return a
distinguished error for “repo not found” and treat everything else
as terminal.)
               
               type VCSError struct {
Err error
}
            
            
            
               
                  deleteCloser
                  struct
                  #
               
               
               deleteCloser is a file that gets deleted on Close.
               
               type deleteCloser struct {
*os.File
}
            
            
            
               
                  gitRepo
                  struct
                  #
               
               
               type gitRepo struct {
ctx context.Context
remote string
remoteURL string
local bool
dir string
mu lockedfile.Mutex
fetchLevel int
statCache *ast.IndexListExpr
refsOnce sync.Once
refs map[string]string
refsErr error
localTagsOnce sync.Once
localTags sync.Map
}
            
            
            
               
                  limitedWriter
                  struct
                  #
               
               
               type limitedWriter struct {
W io.Writer
N int64
ErrLimitReached error
}
            
            
            
               
                  noCommitsError
                  struct
                  #
               
               
               type noCommitsError struct {
}
            
            
            
               
                  notExistError
                  struct
                  #
               
               
               A notExistError wraps another error to retain its original text
but makes it opaquely equivalent to fs.ErrNotExist.
               
               type notExistError struct {
err error
}
            
            
            
               
                  vcsCacheKey
                  struct
                  #
               
               
               type vcsCacheKey struct {
vcs string
remote string
local bool
}
            
            
            
               
                  vcsCmd
                  struct
                  #
               
               
               type vcsCmd struct {
vcs string
init func(remote string) []string
tags func(remote string) []string
tagRE *lazyregexp.Regexp
branches func(remote string) []string
branchRE *lazyregexp.Regexp
badLocalRevRE *lazyregexp.Regexp
statLocal func(rev string, remote string) []string
parseStat func(rev string, out string) (*RevInfo, error)
fetch []string
latest string
readFile func(rev string, file string, remote string) []string
readZip func(rev string, subdir string, remote string, target string) []string
doReadZip func(ctx context.Context, dst io.Writer, workDir string, rev string, subdir string, remote string) error
}
            
            
            
               
                  vcsRepo
                  struct
                  #
               
               
               type vcsRepo struct {
mu lockedfile.Mutex
remote string
cmd *vcsCmd
dir string
local bool
tagsOnce sync.Once
tags map[string]bool
branchesOnce sync.Once
branches map[string]bool
fetchOnce sync.Once
fetchErr error
}
            
            
         
          
         
            Functions
            
            
               
                  AllHex 
                  function
                  
                  #
               
               
               AllHex reports whether the revision rev is entirely lower-case hexadecimal digits.
               
               func AllHex(rev string) bool
            
            
            
               
                  CheckReuse 
                  method
                  
                  #
               
               
               func (r *vcsRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error
            
            
            
               
                  CheckReuse 
                  method
                  
                  #
               
               
               func (r *gitRepo) CheckReuse(ctx context.Context, old *Origin, subdir string) error
            
            
            
               
                  Close 
                  method
                  
                  #
               
               
               func (d *deleteCloser) Close() error
            
            
            
               
                  DescendsFrom 
                  method
                  
                  #
               
               
               func (r *vcsRepo) DescendsFrom(ctx context.Context, rev string, tag string) (bool, error)
            
            
            
               
                  DescendsFrom 
                  method
                  
                  #
               
               
               func (r *gitRepo) DescendsFrom(ctx context.Context, rev string, tag string) (bool, error)
            
            
            
               
                  Error 
                  method
                  
                  #
               
               
               func (e notExistError) Error() string
            
            
            
               
                  Error 
                  method
                  
                  #
               
               
               func (e *UnknownRevisionError) Error() string
            
            
            
               
                  Error 
                  method
                  
                  #
               
               
               func (noCommitsError) Error() string
            
            
            
               
                  Error 
                  method
                  
                  #
               
               
               func (e *RunError) Error() string
            
            
            
               
                  Error 
                  method
                  
                  #
               
               
               func (e *VCSError) Error() string
            
            
            
               
                  Is 
                  method
                  
                  #
               
               
               func (notExistError) Is(err error) bool
            
            
            
               
                  Is 
                  method
                  
                  #
               
               
               func (noCommitsError) Is(err error) bool
            
            
            
               
                  Is 
                  method
                  
                  #
               
               
               func (UnknownRevisionError) Is(err error) bool
            
            
            
               
                  Latest 
                  method
                  
                  #
               
               
               func (r *gitRepo) Latest(ctx context.Context) (*RevInfo, error)
            
            
            
               
                  Latest 
                  method
                  
                  #
               
               
               func (r *vcsRepo) Latest(ctx context.Context) (*RevInfo, error)
            
            
            
               
                  NewRepo 
                  function
                  
                  #
               
               
               func NewRepo(ctx context.Context, vcs string, remote string, local bool) (Repo, error)
            
            
            
               
                  ReadFile 
                  method
                  
                  #
               
               
               func (r *vcsRepo) ReadFile(ctx context.Context, rev string, file string, maxSize int64) ([]byte, error)
            
            
            
               
                  ReadFile 
                  method
                  
                  #
               
               
               func (r *gitRepo) ReadFile(ctx context.Context, rev string, file string, maxSize int64) ([]byte, error)
            
            
            
               
                  ReadZip 
                  method
                  
                  #
               
               
               func (r *vcsRepo) ReadZip(ctx context.Context, rev string, subdir string, maxSize int64) (zip io.ReadCloser, err error)
            
            
            
               
                  ReadZip 
                  method
                  
                  #
               
               
               func (r *gitRepo) ReadZip(ctx context.Context, rev string, subdir string, maxSize int64) (zip io.ReadCloser, err error)
            
            
            
               
                  RecentTag 
                  method
                  
                  #
               
               
               func (r *vcsRepo) RecentTag(ctx context.Context, rev string, prefix string, allowed func(string) bool) (tag string, err error)
            
            
            
               
                  RecentTag 
                  method
                  
                  #
               
               
               func (r *gitRepo) RecentTag(ctx context.Context, rev string, prefix string, allowed func(tag string) bool) (tag string, err error)
            
            
            
               
                  Run 
                  function
                  
                  #
               
               
               Run runs the command line in the given directory
(an empty dir means the current directory).
It returns the standard output and, for a non-zero exit,
a *RunError indicating the command, exit status, and standard error.
Standard error is unavailable for commands that exit successfully.
               
               func Run(ctx context.Context, dir string, cmdline ...any) ([]byte, error)
            
            
            
               
                  RunWithArgs 
                  function
                  
                  #
               
               
               RunWithArgs is the same as Run but it also accepts additional arguments.
               
               func RunWithArgs(ctx context.Context, args RunArgs) ([]byte, error)
            
            
            
               
                  ShortenSHA1 
                  function
                  
                  #
               
               
               ShortenSHA1 shortens a SHA1 hash (40 hex digits) to the canonical length
used in pseudo-versions (12 hex digits).
               
               func ShortenSHA1(rev string) string
            
            
            
               
                  Stat 
                  method
                  
                  #
               
               
               func (r *vcsRepo) Stat(ctx context.Context, rev string) (*RevInfo, error)
            
            
            
               
                  Stat 
                  method
                  
                  #
               
               
               func (r *gitRepo) Stat(ctx context.Context, rev string) (*RevInfo, error)
            
            
            
               
                  Tags 
                  method
                  
                  #
               
               
               func (r *vcsRepo) Tags(ctx context.Context, prefix string) (*Tags, error)
            
            
            
               
                  Tags 
                  method
                  
                  #
               
               
               func (r *gitRepo) Tags(ctx context.Context, prefix string) (*Tags, error)
            
            
            
               
                  Unwrap 
                  method
                  
                  #
               
               
               func (e *VCSError) Unwrap() error
            
            
            
               
                  WorkDir 
                  function
                  
                  #
               
               
               WorkDir returns the name of the cached work directory to use for the
given repository type and name.
               
               func WorkDir(ctx context.Context, typ string, name string) (dir string, lockfile string, err error)
            
            
            
               
                  Write 
                  method
                  
                  #
               
               
               func (l *limitedWriter) Write(p []byte) (n int, err error)
            
            
            
               
                  bzrParseStat 
                  function
                  
                  #
               
               
               func bzrParseStat(rev string, out string) (*RevInfo, error)
            
            
            
               
                  ensureGitAttributes 
                  function
                  
                  #
               
               
               ensureGitAttributes makes sure export-subst and export-ignore features are
disabled for this repo. This is intended to be run prior to running git
archive so that zip files are generated that produce consistent ziphashes
for a given revision, independent of variables such as git version and the
size of the repo.
See: https://github.com/golang/go/issues/27153
               
               func ensureGitAttributes(repoDir string) (err error)
            
            
            
               
                  fetch 
                  method
                  
                  #
               
               
               func (r *vcsRepo) fetch(ctx context.Context)
            
            
            
               
                  fetchRefsLocked 
                  method
                  
                  #
               
               
               fetchRefsLocked fetches all heads and tags from the origin, along with the
ancestors of those commits.
We only fetch heads and tags, not arbitrary other commits: we don't want to
pull in off-branch commits (such as rejected GitHub pull requests) that the
server may be willing to provide. (See the comments within the stat method
for more detail.)
fetchRefsLocked requires that r.mu remain locked for the duration of the call.
               
               func (r *gitRepo) fetchRefsLocked(ctx context.Context) error
            
            
            
               
                  findRef 
                  method
                  
                  #
               
               
               findRef finds some ref name for the given hash,
for use when the server requires giving a ref instead of a hash.
There may be multiple ref names for a given hash,
in which case this returns some name - it doesn't matter which.
               
               func (r *gitRepo) findRef(ctx context.Context, hash string) (ref string, ok bool)
            
            
            
               
                  fossilParseStat 
                  function
                  
                  #
               
               
               func fossilParseStat(rev string, out string) (*RevInfo, error)
            
            
            
               
                  hgParseStat 
                  function
                  
                  #
               
               
               func hgParseStat(rev string, out string) (*RevInfo, error)
            
            
            
               
                  isOriginTag 
                  function
                  
                  #
               
               
               isOriginTag reports whether tag should be preserved
in the Tags method's Origin calculation.
We can safely ignore tags that are not look like pseudo-versions,
because ../coderepo.go's (*codeRepo).Versions ignores them too.
We can also ignore non-semver tags, but we have to include semver
tags with extra suffixes, because the pseudo-version base finder uses them.
               
               func isOriginTag(tag string) bool
            
            
            
               
                  loadBranches 
                  method
                  
                  #
               
               
               func (r *vcsRepo) loadBranches(ctx context.Context)
            
            
            
               
                  loadLocalTags 
                  method
                  
                  #
               
               
               loadLocalTags loads tag references from the local git cache
into the map r.localTags.
               
               func (r *gitRepo) loadLocalTags(ctx context.Context)
            
            
            
               
                  loadRefs 
                  method
                  
                  #
               
               
               loadRefs loads heads and tags references from the remote into the map r.refs.
The result is cached in memory.
               
               func (r *gitRepo) loadRefs(ctx context.Context) (map[string]string, error)
            
            
            
               
                  loadTags 
                  method
                  
                  #
               
               
               func (r *vcsRepo) loadTags(ctx context.Context)
            
            
            
               
                  newGitRepo 
                  function
                  
                  #
               
               
               func newGitRepo(ctx context.Context, remote string, local bool) (Repo, error)
            
            
            
               
                  newVCSRepo 
                  function
                  
                  #
               
               
               func newVCSRepo(ctx context.Context, vcs string, remote string, local bool) (Repo, error)
            
            
            
               
                  repoSum 
                  method
                  
                  #
               
               
               repoSum returns a checksum of the entire repo state,
which can be checked (as Origin.RepoSum) to cache
the absence of a specific module version.
The caller must supply refs, the result of a successful r.loadRefs.
               
               func (r *gitRepo) repoSum(refs map[string]string) string
            
            
            
               
                  run 
                  function
                  
                  #
               
               
               func run(ctx context.Context, args RunArgs) ([]byte, error)
            
            
            
               
                  runGit 
                  method
                  
                  #
               
               
               func (r *gitRepo) runGit(ctx context.Context, cmdline ...any) ([]byte, error)
            
            
            
               
                  stat 
                  method
                  
                  #
               
               
               stat stats the given rev in the local repository,
or else it fetches more info from the remote repository and tries again.
               
               func (r *gitRepo) stat(ctx context.Context, rev string) (info *RevInfo, err error)
            
            
            
               
                  statLocal 
                  method
                  
                  #
               
               
               func (r *vcsRepo) statLocal(ctx context.Context, rev string) (*RevInfo, error)
            
            
            
               
                  statLocal 
                  method
                  
                  #
               
               
               statLocal returns a new RevInfo describing rev in the local git repository.
It uses version as info.Version.
               
               func (r *gitRepo) statLocal(ctx context.Context, version string, rev string) (*RevInfo, error)
            
            
            
               
                  svnParseStat 
                  function
                  
                  #
               
               
               func svnParseStat(rev string, out string) (*RevInfo, error)
            
            
            
               
                  svnReadZip 
                  function
                  
                  #
               
               
               func svnReadZip(ctx context.Context, dst io.Writer, workDir string, rev string, subdir string, remote string) (err error)
            
            
            
               
                  unknownRevisionInfo 
                  method
                  
                  #
               
               
               unknownRevisionInfo returns a RevInfo containing an Origin containing a RepoSum of refs,
for use when returning an UnknownRevisionError.
               
               func (r *gitRepo) unknownRevisionInfo(refs map[string]string) *RevInfo
            
            
            
               
                  vcsErrorf 
                  function
                  
                  #
               
               
               func vcsErrorf(format string, a ...any) error