(ctx context.Context, srcObj, dstDir model.Obj)
| 522 | } |
| 523 | |
| 524 | func (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 | |
| 557 | func (d *Github) Remove(ctx context.Context, obj model.Obj) error { |
| 558 | if !d.isOnBranch { |
nothing calls this directly
no test coverage detected