repo_branch.go (gitea-1.13.1) | : | repo_branch.go (gitea-1.13.2) | ||
---|---|---|---|---|
skipping to change at line 87 | skipping to change at line 87 | |||
b := new(Branch) | b := new(Branch) | |||
resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branche s/%s", user, repo, branch), nil, nil, &b) | resp, err := c.getParsedResponse("GET", fmt.Sprintf("/repos/%s/%s/branche s/%s", user, repo, branch), nil, nil, &b) | |||
if err != nil { | if err != nil { | |||
return nil, resp, err | return nil, resp, err | |||
} | } | |||
return b, resp, nil | return b, resp, nil | |||
} | } | |||
// DeleteRepoBranch delete a branch in a repository | // DeleteRepoBranch delete a branch in a repository | |||
func (c *Client) DeleteRepoBranch(user, repo, branch string) (bool, *Response, e rror) { | func (c *Client) DeleteRepoBranch(user, repo, branch string) (bool, *Response, e rror) { | |||
if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_12_0); err != n il { | |||
return false, nil, err | return false, nil, err | |||
} | } | |||
status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/ branches/%s", user, repo, branch), nil, nil) | status, resp, err := c.getStatusCode("DELETE", fmt.Sprintf("/repos/%s/%s/ branches/%s", user, repo, branch), nil, nil) | |||
if err != nil { | if err != nil { | |||
return false, resp, err | return false, resp, err | |||
} | } | |||
return status == 204, resp, nil | return status == 204, resp, nil | |||
} | } | |||
// CreateBranchOption options when creating a branch in a repository | // CreateBranchOption options when creating a branch in a repository | |||
skipping to change at line 121 | skipping to change at line 121 | |||
return fmt.Errorf("BranchName to long") | return fmt.Errorf("BranchName to long") | |||
} | } | |||
if len(opt.OldBranchName) > 100 { | if len(opt.OldBranchName) > 100 { | |||
return fmt.Errorf("OldBranchName to long") | return fmt.Errorf("OldBranchName to long") | |||
} | } | |||
return nil | return nil | |||
} | } | |||
// CreateBranch creates a branch for a user's repository | // CreateBranch creates a branch for a user's repository | |||
func (c *Client) CreateBranch(owner, repo string, opt CreateBranchOption) (*Bran ch, *Response, error) { | func (c *Client) CreateBranch(owner, repo string, opt CreateBranchOption) (*Bran ch, *Response, error) { | |||
if err := c.CheckServerVersionConstraint(">=1.13.0"); err != nil { | if err := c.checkServerVersionGreaterThanOrEqual(version1_13_0); err != n il { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
if err := opt.Validate(); err != nil { | if err := opt.Validate(); err != nil { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
body, err := json.Marshal(&opt) | body, err := json.Marshal(&opt) | |||
if err != nil { | if err != nil { | |||
return nil, nil, err | return nil, nil, err | |||
} | } | |||
branch := new(Branch) | branch := new(Branch) | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |