本文整理汇总了Golang中github.com/github/git-lfs/git.CurrentRef函数的典型用法代码示例。如果您正苦于以下问题:Golang CurrentRef函数的具体用法?Golang CurrentRef怎么用?Golang CurrentRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CurrentRef函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: checkoutWithIncludeExclude
func checkoutWithIncludeExclude(include []string, exclude []string) {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not checkout")
}
pointers, err := lfs.ScanTree(ref)
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
var wait sync.WaitGroup
wait.Add(1)
c := make(chan *lfs.WrappedPointer)
go func() {
checkoutWithChan(c)
wait.Done()
}()
for _, pointer := range pointers {
if lfs.FilenamePassesIncludeExcludeFilter(pointer.Name, include, exclude) {
c <- pointer
}
}
close(c)
wait.Wait()
}
开发者ID:Kilosassy,项目名称:git-lfs,代码行数:30,代码来源:command_checkout.go
示例2: pullCommand
func pullCommand(cmd *cobra.Command, args []string) {
requireInRepo()
if len(args) > 0 {
// Remote is first arg
if err := git.ValidateRemote(args[0]); err != nil {
Panic(err, fmt.Sprintf("Invalid remote name '%v'", args[0]))
}
lfs.Config.CurrentRemote = args[0]
} else {
// Actively find the default remote, don't just assume origin
defaultRemote, err := git.DefaultRemote()
if err != nil {
Panic(err, "No default remote")
}
lfs.Config.CurrentRemote = defaultRemote
}
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not pull")
}
includePaths, excludePaths := determineIncludeExcludePaths(pullIncludeArg, pullExcludeArg)
c := fetchRefToChan(ref.Sha, includePaths, excludePaths)
checkoutFromFetchChan(includePaths, excludePaths, c)
}
开发者ID:ambf1436,项目名称:git-lfs,代码行数:28,代码来源:command_pull.go
示例3: pruneTaskGetRetainedWorktree
// Background task, must call waitg.Done() once at end
func pruneTaskGetRetainedWorktree(retainChan chan string, errorChan chan error, waitg *sync.WaitGroup) {
defer waitg.Done()
// Retain other worktree HEADs too
// Working copy, branch & maybe commit is different but repo is shared
allWorktreeRefs, err := git.GetAllWorkTreeHEADs(lfs.LocalGitStorageDir)
if err != nil {
errorChan <- err
return
}
// Don't repeat any commits, worktrees are always on their own branches but
// may point to the same commit
commits := lfs.NewStringSet()
// current HEAD is done elsewhere
headref, err := git.CurrentRef()
if err != nil {
errorChan <- err
return
}
commits.Add(headref.Sha)
for _, ref := range allWorktreeRefs {
if commits.Add(ref.Sha) {
// Worktree is on a different commit
waitg.Add(1)
// Don't need to 'cd' to worktree since we share same repo
go pruneTaskGetRetainedAtRef(ref.Sha, retainChan, errorChan, waitg)
}
}
}
开发者ID:strich,项目名称:git-lfs,代码行数:31,代码来源:command_prune.go
示例4: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
var refs []string
if len(args) > 0 {
// Remote is first arg
lfs.Config.CurrentRemote = args[0]
} else {
trackedRemote, err := git.CurrentRemote()
if err == nil {
lfs.Config.CurrentRemote = trackedRemote
} // otherwise leave as default (origin)
}
if len(args) > 1 {
refs = args[1:]
} else {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []string{ref}
}
includePaths, excludePaths := determineIncludeExcludePaths(fetchIncludeArg, fetchExcludeArg)
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
fetchRef(ref, includePaths, excludePaths)
}
}
开发者ID:GeorgeR,项目名称:git-lfs,代码行数:30,代码来源:command_fetch.go
示例5: lsFilesCommand
func lsFilesCommand(cmd *cobra.Command, args []string) {
requireInRepo()
var ref string
var err error
if len(args) == 1 {
ref = args[0]
} else {
fullref, err := git.CurrentRef()
if err != nil {
Exit(err.Error())
}
ref = fullref.Sha
}
showOidLen := 10
if longOIDs {
showOidLen = 64
}
files, err := lfs.ScanTree(ref)
if err != nil {
Panic(err, "Could not scan for Git LFS tree: %s", err)
}
for _, p := range files {
Print("%s %s %s", p.Oid[0:showOidLen], lsFilesMarker(p), p.Name)
}
}
开发者ID:2012781508623add,项目名称:git-lfs,代码行数:30,代码来源:command_ls_files.go
示例6: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
requireInRepo()
var refs []*git.Ref
if len(args) > 0 {
// Remote is first arg
lfs.Config.CurrentRemote = args[0]
} else {
trackedRemote, err := git.CurrentRemote()
if err == nil {
lfs.Config.CurrentRemote = trackedRemote
} // otherwise leave as default (origin)
}
if len(args) > 1 {
for _, r := range args[1:] {
ref, err := git.ResolveRef(r)
if err != nil {
Panic(err, "Invalid ref argument")
}
refs = append(refs, ref)
}
} else {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []*git.Ref{ref}
}
if fetchAllArg {
if fetchRecentArg || len(args) > 1 {
Exit("Cannot combine --all with ref arguments or --recent")
}
if fetchIncludeArg != "" || fetchExcludeArg != "" {
Exit("Cannot combine --all with --include or --exclude")
}
if len(lfs.Config.FetchIncludePaths()) > 0 || len(lfs.Config.FetchExcludePaths()) > 0 {
Print("Ignoring global include / exclude paths to fulfil --all")
}
fetchAll()
} else { // !all
includePaths, excludePaths := determineIncludeExcludePaths(fetchIncludeArg, fetchExcludeArg)
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
Print("Fetching %v", ref.Name)
fetchRef(ref.Sha, includePaths, excludePaths)
}
if fetchRecentArg || lfs.Config.FetchPruneConfig().FetchRecentAlways {
fetchRecent(refs, includePaths, excludePaths)
}
}
}
开发者ID:nakaeeee,项目名称:git-lfs,代码行数:57,代码来源:command_fetch.go
示例7: pull
func pull(includePaths, excludePaths []string) {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not pull")
}
c := fetchRefToChan(ref.Sha, includePaths, excludePaths)
checkoutFromFetchChan(includePaths, excludePaths, c)
}
开发者ID:zhaohaiyi,项目名称:git-lfs,代码行数:11,代码来源:command_pull.go
示例8: pruneTaskGetRetainedCurrentAndRecentRefs
// Background task, must call waitg.Done() once at end
func pruneTaskGetRetainedCurrentAndRecentRefs(retainChan chan string, errorChan chan error, waitg *sync.WaitGroup) {
defer waitg.Done()
// We actually increment the waitg in this func since we kick off sub-goroutines
// Make a list of what unique commits to keep, & search backward from
commits := lfs.NewStringSet()
// Do current first
ref, err := git.CurrentRef()
if err != nil {
errorChan <- err
return
}
commits.Add(ref.Sha)
waitg.Add(1)
go pruneTaskGetRetainedAtRef(ref.Sha, retainChan, errorChan, waitg)
// Now recent
fetchconf := lfs.Config.FetchPruneConfig()
if fetchconf.FetchRecentRefsDays > 0 {
pruneRefDays := fetchconf.FetchRecentRefsDays + fetchconf.PruneOffsetDays
tracerx.Printf("PRUNE: Retaining non-HEAD refs within %d (%d+%d) days", pruneRefDays, fetchconf.FetchRecentRefsDays, fetchconf.PruneOffsetDays)
refsSince := time.Now().AddDate(0, 0, -pruneRefDays)
// Keep all recent refs including any recent remote branches
refs, err := git.RecentBranches(refsSince, fetchconf.FetchRecentRefsIncludeRemotes, "")
if err != nil {
Panic(err, "Could not scan for recent refs")
}
for _, ref := range refs {
if commits.Add(ref.Sha) {
// A new commit
waitg.Add(1)
go pruneTaskGetRetainedAtRef(ref.Sha, retainChan, errorChan, waitg)
}
}
}
// For every unique commit we've fetched, check recent commits too
// Only if we're fetching recent commits, otherwise only keep at refs
if fetchconf.FetchRecentCommitsDays > 0 {
pruneCommitDays := fetchconf.FetchRecentCommitsDays + fetchconf.PruneOffsetDays
for commit := range commits.Iter() {
// We measure from the last commit at the ref
summ, err := git.GetCommitSummary(commit)
if err != nil {
errorChan <- fmt.Errorf("Couldn't scan commits at %v: %v", commit, err)
continue
}
commitsSince := summ.CommitDate.AddDate(0, 0, -pruneCommitDays)
waitg.Add(1)
go pruneTaskGetPreviousVersionsOfRef(commit, commitsSince, retainChan, errorChan, waitg)
}
}
}
开发者ID:strich,项目名称:git-lfs,代码行数:54,代码来源:command_prune.go
示例9: checkoutWithIncludeExclude
func checkoutWithIncludeExclude(include []string, exclude []string) {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not checkout")
}
pointers, err := lfs.ScanTree(ref.Sha)
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
var wait sync.WaitGroup
wait.Add(1)
c := make(chan *lfs.WrappedPointer, 1)
go func() {
checkoutWithChan(c)
wait.Done()
}()
// Count bytes for progress
var totalBytes int64
for _, pointer := range pointers {
totalBytes += pointer.Size
}
logPath, _ := cfg.Os.Get("GIT_LFS_PROGRESS")
progress := progress.NewProgressMeter(len(pointers), totalBytes, false, logPath)
progress.Start()
totalBytes = 0
for _, pointer := range pointers {
totalBytes += pointer.Size
if lfs.FilenamePassesIncludeExcludeFilter(pointer.Name, include, exclude) {
progress.Add(pointer.Name)
c <- pointer
// not strictly correct (parallel) but we don't have a callback & it's just local
// plus only 1 slot in channel so it'll block & be close
progress.TransferBytes("checkout", pointer.Name, pointer.Size, totalBytes, int(pointer.Size))
progress.FinishTransfer(pointer.Name)
} else {
progress.Skip(pointer.Size)
}
}
close(c)
wait.Wait()
progress.Finish()
}
开发者ID:zhaohaiyi,项目名称:git-lfs,代码行数:49,代码来源:command_checkout.go
示例10: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
var refs []string
if len(args) > 0 {
refs = args
} else {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []string{ref}
}
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
fetchRef(ref)
}
}
开发者ID:JeckoHeroOrg,项目名称:-git-lfs_miilkyway,代码行数:19,代码来源:command_fetch.go
示例11: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
var refs []*git.Ref
if len(args) > 0 {
// Remote is first arg
lfs.Config.CurrentRemote = args[0]
} else {
trackedRemote, err := git.CurrentRemote()
if err == nil {
lfs.Config.CurrentRemote = trackedRemote
} // otherwise leave as default (origin)
}
if len(args) > 1 {
for _, r := range args[1:] {
ref, err := git.ResolveRef(r)
if err != nil {
Panic(err, "Invalid ref argument")
}
refs = append(refs, ref)
}
} else {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []*git.Ref{ref}
}
includePaths, excludePaths := determineIncludeExcludePaths(fetchIncludeArg, fetchExcludeArg)
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
Print("Fetching %v", ref.Name)
fetchRef(ref.Sha, includePaths, excludePaths)
}
if fetchRecentArg || lfs.Config.FetchPruneConfig().FetchRecentAlways {
fetchRecent(refs, includePaths, excludePaths)
}
}
开发者ID:crealytics,项目名称:git-lfs,代码行数:41,代码来源:command_fetch.go
示例12: checkoutFromFetchChan
func checkoutFromFetchChan(include []string, exclude []string, in chan *lfs.WrappedPointer) {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not checkout")
}
// Need to ScanTree to identify multiple files with the same content (fetch will only report oids once)
pointers, err := lfs.ScanTree(ref.Sha)
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
// Map oid to multiple pointers
mapping := make(map[string][]*lfs.WrappedPointer)
for _, pointer := range pointers {
if lfs.FilenamePassesIncludeExcludeFilter(pointer.Name, include, exclude) {
mapping[pointer.Oid] = append(mapping[pointer.Oid], pointer)
}
}
// Launch git update-index
c := make(chan *lfs.WrappedPointer)
var wait sync.WaitGroup
wait.Add(1)
go func() {
checkoutWithChan(c)
wait.Done()
}()
// Feed it from in, which comes from fetch
for p := range in {
// Add all of the files for this oid
for _, fp := range mapping[p.Oid] {
c <- fp
}
}
close(c)
wait.Wait()
}
开发者ID:crealytics,项目名称:git-lfs,代码行数:40,代码来源:command_checkout.go
示例13: lsFilesCommand
func lsFilesCommand(cmd *cobra.Command, args []string) {
var ref string
var err error
if len(args) == 1 {
ref = args[0]
} else {
ref, err = git.CurrentRef()
if err != nil {
Panic(err, "Could not ls-files")
}
}
pointers, err := lfs.ScanRefs(ref, "")
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
for _, p := range pointers {
Print(p.Name)
}
}
开发者ID:devcurmudgeon,项目名称:git-lfs,代码行数:22,代码来源:command_ls_files.go
示例14: pullCommand
func pullCommand(cmd *cobra.Command, args []string) {
if len(args) > 0 {
// Remote is first arg
lfs.Config.CurrentRemote = args[0]
} else {
trackedRemote, err := git.CurrentRemote()
if err == nil {
lfs.Config.CurrentRemote = trackedRemote
} // otherwise leave as default (origin)
}
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not pull")
}
includePaths, excludePaths := determineIncludeExcludePaths(pullIncludeArg, pullExcludeArg)
c := fetchRefToChan(ref, includePaths, excludePaths)
checkoutFromFetchChan(includePaths, excludePaths, c)
}
开发者ID:sanoursa,项目名称:git-lfs,代码行数:22,代码来源:command_pull.go
示例15: lsFilesCommand
func lsFilesCommand(cmd *cobra.Command, args []string) {
var ref string
var err error
if len(args) == 1 {
ref = args[0]
} else {
fullref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not ls-files")
}
ref = fullref.Sha
}
scanOpt := &lfs.ScanRefsOptions{SkipDeletedBlobs: true}
pointers, err := lfs.ScanRefs(ref, "", scanOpt)
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
for _, p := range pointers {
Print(p.Name)
}
}
开发者ID:yonatanp,项目名称:git-lfs,代码行数:24,代码来源:command_ls_files.go
示例16: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
requireInRepo()
var refs []*git.Ref
if len(args) > 0 {
// Remote is first arg
if err := git.ValidateRemote(args[0]); err != nil {
Exit("Invalid remote name %q", args[0])
}
cfg.CurrentRemote = args[0]
} else {
cfg.CurrentRemote = ""
}
if len(args) > 1 {
resolvedrefs, err := git.ResolveRefs(args[1:])
if err != nil {
Panic(err, "Invalid ref argument: %v", args[1:])
}
refs = resolvedrefs
} else if !fetchAllArg {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []*git.Ref{ref}
}
success := true
include, exclude := getIncludeExcludeArgs(cmd)
if fetchAllArg {
if fetchRecentArg || len(args) > 1 {
Exit("Cannot combine --all with ref arguments or --recent")
}
if include != nil || exclude != nil {
Exit("Cannot combine --all with --include or --exclude")
}
if len(cfg.FetchIncludePaths()) > 0 || len(cfg.FetchExcludePaths()) > 0 {
Print("Ignoring global include / exclude paths to fulfil --all")
}
success = fetchAll()
} else { // !all
includePaths, excludePaths := determineIncludeExcludePaths(cfg, include, exclude)
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
Print("Fetching %v", ref.Name)
s := fetchRef(ref.Sha, includePaths, excludePaths)
success = success && s
}
if fetchRecentArg || cfg.FetchPruneConfig().FetchRecentAlways {
s := fetchRecent(refs, includePaths, excludePaths)
success = success && s
}
}
if fetchPruneArg {
fetchconf := cfg.FetchPruneConfig()
verify := fetchconf.PruneVerifyRemoteAlways
// no dry-run or verbose options in fetch, assume false
prune(fetchconf, verify, false, false)
}
if !success {
Exit("Warning: errors occurred")
}
}
开发者ID:zhaohaiyi,项目名称:git-lfs,代码行数:71,代码来源:command_fetch.go
示例17: doFsck
func doFsck() (bool, error) {
requireInRepo()
ref, err := git.CurrentRef()
if err != nil {
return false, err
}
// The LFS scanner methods return unexported *lfs.wrappedPointer objects.
// All we care about is the pointer OID and file name
pointerIndex := make(map[string]string)
pointers, err := lfs.ScanRefs(ref.Sha, "", nil)
if err != nil {
return false, err
}
for _, p := range pointers {
pointerIndex[p.Oid] = p.Name
}
// TODO(zeroshirts): do we want to look for LFS stuff in past commits?
p2, err := lfs.ScanIndex()
if err != nil {
return false, err
}
for _, p := range p2 {
pointerIndex[p.Oid] = p.Name
}
ok := true
for oid, name := range pointerIndex {
path := lfs.LocalMediaPathReadOnly(oid)
Debug("Examining %v (%v)", name, path)
f, err := os.Open(path)
if pErr, pOk := err.(*os.PathError); pOk {
Print("Object %s (%s) could not be checked: %s", name, oid, pErr.Err)
ok = false
continue
}
if err != nil {
return false, err
}
oidHash := sha256.New()
_, err = io.Copy(oidHash, f)
f.Close()
if err != nil {
return false, err
}
recalculatedOid := hex.EncodeToString(oidHash.Sum(nil))
if recalculatedOid != oid {
ok = false
Print("Object %s (%s) is corrupt", name, oid)
if fsckDryRun {
continue
}
badDir := filepath.Join(config.LocalGitStorageDir, "lfs", "bad")
if err := os.MkdirAll(badDir, 0755); err != nil {
return false, err
}
badFile := filepath.Join(badDir, oid)
if err := os.Rename(path, badFile); err != nil {
return false, err
}
Print(" moved to %s", badFile)
}
}
return ok, nil
}
开发者ID:zhaohaiyi,项目名称:git-lfs,代码行数:77,代码来源:command_fsck.go
示例18: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
var ref string
var err error
if len(args) == 1 {
ref = args[0]
} else {
ref, err = git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
}
pointers, err := lfs.ScanRefs(ref, "")
if err != nil {
Panic(err, "Could not scan for Git LFS files")
}
q := lfs.NewDownloadQueue(lfs.Config.ConcurrentTransfers(), len(pointers))
for _, p := range pointers {
q.Add(lfs.NewDownloadable(p))
}
target, err := git.ResolveRef(ref)
if err != nil {
Panic(err, "Could not resolve git ref")
}
current, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch the current git ref")
}
if target == current {
// We just downloaded the files for the current ref, we can copy them into
// the working directory and update the git index. We're doing this in a
// goroutine so they can be copied as they come in, for efficiency.
watch := q.Watch()
go func() {
files := make(map[string]*lfs.WrappedPointer, len(pointers))
for _, pointer := range pointers {
files[pointer.Oid] = pointer
}
// Fire up the update-index command
cmd := exec.Command("git", "update-index", "-q", "--refresh", "--stdin")
stdin, err := cmd.StdinPipe()
if err != nil {
Panic(err, "Could not update the index")
}
if err := cmd.Start(); err != nil {
Panic(err, "Could not update the index")
}
// As files come in, write them to the wd and update the index
for oid := range watch {
pointer, ok := files[oid]
if !ok {
continue
}
file, err := os.Create(pointer.Name)
if err != nil {
Panic(err, "Could not create working directory file")
}
if err := lfs.PointerSmudge(file, pointer.Pointer, pointer.Name, nil); err != nil {
Panic(err, "Could not write working directory file")
}
file.Close()
stdin.Write([]byte(pointer.Name + "\n"))
}
stdin.Close()
if err := cmd.Wait(); err != nil {
Panic(err, "Error updating the git index")
}
}()
processQueue := time.Now()
q.Process()
tracerx.PerformanceSince("process queue", processQueue)
}
}
开发者ID:miumok98,项目名称:git-lfs,代码行数:88,代码来源:command_fetch.go
示例19: pushCommand
// pushCommand pushes local objects to a Git LFS server. It takes two
// arguments:
//
// `<remote> <remote ref>`
//
// Both a remote name ("origin") or a remote URL are accepted.
//
// pushCommand calculates the git objects to send by looking comparing the range
// of commits between the local and remote git servers.
func pushCommand(cmd *cobra.Command, args []string) {
var uploadQueue *lfs.TransferQueue
if len(args) == 0 {
Print("Specify a remote and a remote branch name (`git lfs push origin master`)")
os.Exit(1)
}
lfs.Config.CurrentRemote = args[0]
if useStdin {
requireStdin("Run this command from the Git pre-push hook, or leave the --stdin flag off.")
// called from a pre-push hook! Update the existing pre-push hook if it's
// one that git-lfs set.
lfs.InstallHooks(false)
refsData, err := ioutil.ReadAll(os.Stdin)
if err != nil {
Panic(err, "Error reading refs on stdin")
}
if len(refsData) == 0 {
return
}
left, right := decodeRefs(string(refsData))
if left == pushDeleteBranch {
return
}
uploadQueue = uploadsBetweenRefs(left, right)
} else if pushObjectIDs {
if len(args) < 2 {
Print("Usage: git lfs push --object-id <remote> <lfs-object-id> [lfs-object-id] ...")
return
}
uploadQueue = uploadsWithObjectIDs(args[1:])
} else {
if len(args) < 1 {
Print("Usage: git lfs push --dry-run <remote> [ref]")
return
}
remote := args[0]
var ref string
if len(args) == 2 {
ref = args[1]
}
if ref == "" {
localRef, err := git.CurrentRef()
if err != nil {
Panic(err, "Error getting local ref")
}
ref = localRef.Sha
}
uploadQueue = uploadsBetweenRefAndRemote(ref, remote)
}
if !pushDryRun {
uploadQueue.Wait()
for _, err := range uploadQueue.Errors() {
if Debugging || err.Panic {
LoggedError(err.Err, err.Error())
} else {
Error(err.Error())
}
}
if len(uploadQueue.Errors()) > 0 {
os.Exit(2)
}
}
}
开发者ID:crealytics,项目名称:git-lfs,代码行数:87,代码来源:command_push.go
示例20: fetchCommand
func fetchCommand(cmd *cobra.Command, args []string) {
requireInRepo()
var refs []*git.Ref
if len(args) > 0 {
// Remote is first arg
if err := git.ValidateRemote(args[0]); err != nil {
Exit("Invalid remote name %q", args[0])
}
lfs.Config.CurrentRemote = args[0]
} else {
// Actively find the default remote, don't just assume origin
defaultRemote, err := git.DefaultRemote()
if err != nil {
Exit("No default remote")
}
lfs.Config.CurrentRemote = defaultRemote
}
if len(args) > 1 {
for _, r := range args[1:] {
ref, err := git.ResolveRef(r)
if err != nil {
Panic(err, "Invalid ref argument")
}
refs = append(refs, ref)
}
} else {
ref, err := git.CurrentRef()
if err != nil {
Panic(err, "Could not fetch")
}
refs = []*git.Ref{ref}
}
success := true
if fetchAllArg {
if fetchRecentArg || len(args) > 1 {
Exit("Cannot combine --all with ref arguments or --recent")
}
if fetchIncludeArg != "" || fetchExcludeArg != "" {
Exit("Cannot combine --all with --include or --exclude")
}
if len(lfs.Config.FetchIncludePaths()) > 0 || len(lfs.Config.FetchExcludePaths()) > 0 {
Print("Ignoring global include / exclude paths to fulfil --all")
}
success = fetchAll()
} else { // !all
includePaths, excludePaths := determineIncludeExcludePaths(fetchIncludeArg, fetchExcludeArg)
// Fetch refs sequentially per arg order; duplicates in later refs will be ignored
for _, ref := range refs {
Print("Fetching %v", ref.Name)
s := fetchRef(ref.Sha, includePaths, excludePaths)
success = success && s
}
if fetchRecentArg || lfs.Config.FetchPruneConfig().FetchRecentAlways {
s := fetchRecent(refs, includePaths, excludePaths)
success = success && s
}
}
if fetchPruneArg {
verify := lfs.Config.FetchPruneConfig().PruneVerifyRemoteAlways
// no dry-run or verbose options in fetch, assume false
prune(verify, false, false)
}
if !success {
Exit("Warning: errors occurred")
}
}
开发者ID:ambf1436,项目名称:git-lfs,代码行数:75,代码来源:command_fetch.go
注:本文中的github.com/github/git-lfs/git.CurrentRef函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论