MCPcopy
hub / github.com/AlistGo/alist / newTree

Method newTree

drivers/github/driver.go:807–825  ·  view source on GitHub ↗
(baseSha string, tree []interface{})

Source from the content-addressed store, hash-verified

805}
806
807func (d *Github) newTree(baseSha string, tree []interface{}) (string, error) {
808 body := &TreeReq{Trees: tree}
809 if baseSha != "" {
810 body.BaseTree = baseSha
811 }
812 res, err := d.client.R().SetBody(body).
813 Post(fmt.Sprintf("https://api.github.com/repos/%s/%s/git/trees", d.Owner, d.Repo))
814 if err != nil {
815 return "", err
816 }
817 if res.StatusCode() != 201 {
818 return "", toErr(res)
819 }
820 var resp TreeResp
821 if err = utils.Json.Unmarshal(res.Body(), &resp); err != nil {
822 return "", err
823 }
824 return resp.Sha, nil
825}
826
827func (d *Github) commit(message, treeSha string) error {
828 oldCommit, err := d.getBranchHead()

Callers 7

MakeDirMethod · 0.95
MoveMethod · 0.95
RenameMethod · 0.95
RemoveMethod · 0.95
PutMethod · 0.95
renewParentTreesMethod · 0.95
copyWithoutRenewTreeMethod · 0.95

Calls 3

PostMethod · 0.80
toErrFunction · 0.70
UnmarshalMethod · 0.45

Tested by

no test coverage detected