MCPcopy Index your code
hub / github.com/OpenListTeam/OpenList / Copy

Method Copy

drivers/github/driver.go:524–555  ·  view source on GitHub ↗
(ctx context.Context, srcObj, dstDir model.Obj)

Source from the content-addressed store, hash-verified

522}
523
524func (d *Github) Copy(ctx context.Context, srcObj, dstDir model.Obj) error {
525 if !d.isOnBranch {
526 return errors.New("cannot write to non-branch reference")
527 }
528 if strings.HasPrefix(dstDir.GetPath(), srcObj.GetPath()) {
529 return errors.New("cannot copy parent dir to child")
530 }
531 d.commitMutex.Lock()
532 defer d.commitMutex.Unlock()
533
534 dstSha, newSha, _, _, err := d.copyWithoutRenewTree(srcObj, dstDir)
535 if err != nil {
536 return err
537 }
538 rootSha, err := d.renewParentTrees(dstDir.GetPath(), dstSha, newSha, "/")
539 if err != nil {
540 return err
541 }
542 message, err := getMessage(d.copyMsgTmpl, &MessageTemplateVars{
543 UserName: getUsername(ctx),
544 ObjName: srcObj.GetName(),
545 ObjPath: srcObj.GetPath(),
546 ParentName: stdpath.Base(stdpath.Dir(srcObj.GetPath())),
547 ParentPath: stdpath.Dir(srcObj.GetPath()),
548 TargetName: stdpath.Base(dstDir.GetPath()),
549 TargetPath: dstDir.GetPath(),
550 }, "copy")
551 if err != nil {
552 return err
553 }
554 return d.commit(message, rootSha)
555}
556
557func (d *Github) Remove(ctx context.Context, obj model.Obj) error {
558 if !d.isOnBranch {

Callers

nothing calls this directly

Calls 8

copyWithoutRenewTreeMethod · 0.95
renewParentTreesMethod · 0.95
commitMethod · 0.95
getMessageFunction · 0.85
getUsernameFunction · 0.85
GetPathMethod · 0.65
UnlockMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected