mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-06 03:08:44 +02:00
Merge branch 'main' into lunny/add_reply_code_review
This commit is contained in:
@@ -4,21 +4,23 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/config"
|
||||
"gitea.dev/tea/modules/print"
|
||||
)
|
||||
|
||||
// CreateIssue creates an issue in the given repo and prints the result
|
||||
func CreateIssue(login *config.Login, repoOwner, repoName string, opts gitea.CreateIssueOption) error {
|
||||
func CreateIssue(requestCtx stdctx.Context, rlogin *config.Login, repoOwner, repoName string, opts gitea.CreateIssueOption) error {
|
||||
// title is required
|
||||
if len(opts.Title) == 0 {
|
||||
return fmt.Errorf("title is required")
|
||||
}
|
||||
|
||||
issue, _, err := login.Client().CreateIssue(repoOwner, repoName, opts)
|
||||
issue, _, err := rlogin.Client().Issues.CreateIssue(requestCtx, repoOwner, repoName, opts)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create issue: %s", err)
|
||||
}
|
||||
|
||||
+13
-11
@@ -4,11 +4,13 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/context"
|
||||
)
|
||||
|
||||
// EditIssueOption wraps around gitea.EditIssueOption which has bad & incosistent semantics.
|
||||
@@ -29,12 +31,12 @@ type EditIssueOption struct {
|
||||
|
||||
// Normalizes the options into parameters that can be passed to the sdk.
|
||||
// the returned value will be nil, when no change to this part of the issue is requested.
|
||||
func (o EditIssueOption) toSdkOptions(ctx *context.TeaContext, client *gitea.Client) (*gitea.EditIssueOption, *gitea.IssueLabelsOption, *gitea.IssueLabelsOption, error) {
|
||||
addLabelOpts, err := ResolveLabelOpts(client, ctx.Owner, ctx.Repo, o.AddLabels)
|
||||
func (o EditIssueOption) toSdkOptions(requestCtx stdctx.Context, ctx *context.TeaContext, client *gitea.Client) (*gitea.EditIssueOption, *gitea.IssueLabelsOption, *gitea.IssueLabelsOption, error) {
|
||||
addLabelOpts, err := ResolveLabelOpts(requestCtx, client, ctx.Owner, ctx.Repo, o.AddLabels)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
rmLabelOpts, err := ResolveLabelOpts(client, ctx.Owner, ctx.Repo, o.RemoveLabels)
|
||||
rmLabelOpts, err := ResolveLabelOpts(requestCtx, client, ctx.Owner, ctx.Repo, o.RemoveLabels)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -54,7 +56,7 @@ func (o EditIssueOption) toSdkOptions(ctx *context.TeaContext, client *gitea.Cli
|
||||
issueOptsDirty = true
|
||||
}
|
||||
if o.Milestone != nil {
|
||||
id, err := ResolveMilestoneID(client, ctx.Owner, ctx.Repo, *o.Milestone)
|
||||
id, err := ResolveMilestoneID(requestCtx, client, ctx.Owner, ctx.Repo, *o.Milestone)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
@@ -80,28 +82,28 @@ func (o EditIssueOption) toSdkOptions(ctx *context.TeaContext, client *gitea.Cli
|
||||
}
|
||||
|
||||
// EditIssue edits an issue and returns the updated issue.
|
||||
func EditIssue(ctx *context.TeaContext, client *gitea.Client, opts EditIssueOption) (*gitea.Issue, error) {
|
||||
func EditIssue(requestCtx stdctx.Context, ctx *context.TeaContext, client *gitea.Client, opts EditIssueOption) (*gitea.Issue, error) {
|
||||
if client == nil {
|
||||
client = ctx.Login.Client()
|
||||
}
|
||||
|
||||
issueOpts, addLabelOpts, rmLabelOpts, err := opts.toSdkOptions(ctx, client)
|
||||
issueOpts, addLabelOpts, rmLabelOpts, err := opts.toSdkOptions(requestCtx, ctx, client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := ApplyLabelChanges(client, ctx.Owner, ctx.Repo, opts.Index, addLabelOpts, rmLabelOpts); err != nil {
|
||||
if err := ApplyLabelChanges(requestCtx, client, ctx.Owner, ctx.Repo, opts.Index, addLabelOpts, rmLabelOpts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var issue *gitea.Issue
|
||||
if issueOpts != nil {
|
||||
issue, _, err = client.EditIssue(ctx.Owner, ctx.Repo, opts.Index, *issueOpts)
|
||||
issue, _, err = client.Issues.EditIssue(requestCtx, ctx.Owner, ctx.Repo, opts.Index, *issueOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not edit issue: %s", err)
|
||||
}
|
||||
} else {
|
||||
issue, _, err = client.GetIssue(ctx.Owner, ctx.Repo, opts.Index)
|
||||
issue, _, err = client.Issues.GetIssue(requestCtx, ctx.Owner, ctx.Repo, opts.Index)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get issue: %s", err)
|
||||
}
|
||||
|
||||
+16
-14
@@ -4,18 +4,20 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/utils"
|
||||
)
|
||||
|
||||
// ResolveLabelNames returns a list of label IDs for a given list of label names
|
||||
func ResolveLabelNames(client *gitea.Client, owner, repo string, labelNames []string) ([]int64, error) {
|
||||
func ResolveLabelNames(requestCtx stdctx.Context, client *gitea.Client, owner, repo string, labelNames []string) ([]int64, error) {
|
||||
labelIDs := make([]int64, 0, len(labelNames))
|
||||
page := 1
|
||||
for {
|
||||
labels, resp, err := client.ListRepoLabels(owner, repo, gitea.ListLabelsOptions{
|
||||
labels, resp, err := client.Repositories.ListRepoLabels(requestCtx, owner, repo, gitea.ListLabelsOptions{
|
||||
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -35,11 +37,11 @@ func ResolveLabelNames(client *gitea.Client, owner, repo string, labelNames []st
|
||||
}
|
||||
|
||||
// ResolveLabelOpts resolves label names to IssueLabelsOption. Returns nil if names is empty.
|
||||
func ResolveLabelOpts(client *gitea.Client, owner, repo string, names []string) (*gitea.IssueLabelsOption, error) {
|
||||
func ResolveLabelOpts(requestCtx stdctx.Context, client *gitea.Client, owner, repo string, names []string) (*gitea.IssueLabelsOption, error) {
|
||||
if len(names) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
ids, err := ResolveLabelNames(client, owner, repo, names)
|
||||
ids, err := ResolveLabelNames(requestCtx, client, owner, repo, names)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -47,18 +49,18 @@ func ResolveLabelOpts(client *gitea.Client, owner, repo string, names []string)
|
||||
}
|
||||
|
||||
// ApplyLabelChanges adds and removes labels on an issue or pull request.
|
||||
func ApplyLabelChanges(client *gitea.Client, owner, repo string, index int64, add, rm *gitea.IssueLabelsOption) error {
|
||||
func ApplyLabelChanges(requestCtx stdctx.Context, client *gitea.Client, owner, repo string, index int64, add, rm *gitea.IssueLabelsOption) error {
|
||||
if rm != nil {
|
||||
// NOTE: as of 1.17, there is no API to remove multiple labels at once.
|
||||
for _, id := range rm.Labels {
|
||||
_, err := client.DeleteIssueLabel(owner, repo, index, id)
|
||||
_, err := client.Issues.DeleteIssueLabel(requestCtx, owner, repo, index, id)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not remove labels: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
if add != nil {
|
||||
_, _, err := client.AddIssueLabels(owner, repo, index, *add)
|
||||
_, _, err := client.Issues.AddIssueLabels(requestCtx, owner, repo, index, *add)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not add labels: %s", err)
|
||||
}
|
||||
@@ -67,9 +69,9 @@ func ApplyLabelChanges(client *gitea.Client, owner, repo string, index int64, ad
|
||||
}
|
||||
|
||||
// ApplyReviewerChanges adds and removes reviewers on a pull request.
|
||||
func ApplyReviewerChanges(client *gitea.Client, owner, repo string, index int64, add, rm []string) error {
|
||||
func ApplyReviewerChanges(requestCtx stdctx.Context, client *gitea.Client, owner, repo string, index int64, add, rm []string) error {
|
||||
if len(rm) != 0 {
|
||||
_, err := client.DeleteReviewRequests(owner, repo, index, gitea.PullReviewRequestOptions{
|
||||
_, err := client.PullRequests.DeleteReviewRequests(requestCtx, owner, repo, index, gitea.PullReviewRequestOptions{
|
||||
Reviewers: rm,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -77,7 +79,7 @@ func ApplyReviewerChanges(client *gitea.Client, owner, repo string, index int64,
|
||||
}
|
||||
}
|
||||
if len(add) != 0 {
|
||||
_, err := client.CreateReviewRequests(owner, repo, index, gitea.PullReviewRequestOptions{
|
||||
_, err := client.PullRequests.CreateReviewRequests(requestCtx, owner, repo, index, gitea.PullReviewRequestOptions{
|
||||
Reviewers: add,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -88,11 +90,11 @@ func ApplyReviewerChanges(client *gitea.Client, owner, repo string, index int64,
|
||||
}
|
||||
|
||||
// ResolveMilestoneID resolves a milestone name to its ID. Returns 0 for empty name.
|
||||
func ResolveMilestoneID(client *gitea.Client, owner, repo, name string) (int64, error) {
|
||||
func ResolveMilestoneID(requestCtx stdctx.Context, client *gitea.Client, owner, repo, name string) (int64, error) {
|
||||
if name == "" {
|
||||
return 0, nil
|
||||
}
|
||||
ms, _, err := client.GetMilestoneByName(owner, repo, name)
|
||||
ms, _, err := client.Repositories.GetMilestoneByName(requestCtx, owner, repo, name)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("could not resolve milestone '%s': %w", name, err)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/sdk"
|
||||
)
|
||||
|
||||
// LabelsExport save list of labels to disc
|
||||
|
||||
@@ -4,16 +4,17 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/tea/modules/config"
|
||||
"gitea.dev/tea/modules/utils"
|
||||
)
|
||||
|
||||
// SetupHelper add tea helper to config global
|
||||
@@ -48,7 +49,7 @@ func SetupHelper(login config.Login) (ok bool, err error) {
|
||||
}
|
||||
|
||||
// CreateLogin create a login to be stored in config
|
||||
func CreateLogin(name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCertPrincipal, sshKeyFingerprint string, insecure, sshAgent, versionCheck, addHelper bool) error {
|
||||
func CreateLogin(ctx stdctx.Context, name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCertPrincipal, sshKeyFingerprint string, insecure, sshAgent, versionCheck, addHelper bool) error {
|
||||
// checks ...
|
||||
// ... if we have a url
|
||||
if len(giteaURL) == 0 {
|
||||
@@ -105,7 +106,7 @@ func CreateLogin(name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCe
|
||||
}
|
||||
|
||||
if len(token) == 0 && sshCertPrincipal == "" && !sshAgent && sshKey == "" {
|
||||
if login.Token, err = generateToken(login, user, passwd, otp, scopes); err != nil {
|
||||
if login.Token, err = generateToken(ctx, login, user, passwd, otp, scopes); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -113,7 +114,7 @@ func CreateLogin(name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCe
|
||||
client := login.Client()
|
||||
|
||||
// Verify if authentication works and get user info
|
||||
u, _, err := client.GetMyUserInfo()
|
||||
u, _, err := client.Users.GetMyUserInfo(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -130,7 +131,7 @@ func CreateLogin(name, token, user, passwd, otp, scopes, sshKey, giteaURL, sshCe
|
||||
login.SSHHost = serverURL.Host
|
||||
|
||||
if len(sshKey) == 0 {
|
||||
login.SSHKey, err = findSSHKey(client)
|
||||
login.SSHKey, err = findSSHKey(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Printf("Warning: problem while finding a SSH key: %s\n", err)
|
||||
}
|
||||
@@ -159,7 +160,7 @@ func shouldCheckTokenUniqueness(token string, sshAgent bool, sshKey, sshCertPrin
|
||||
}
|
||||
|
||||
// generateToken creates a new token when given BasicAuth credentials
|
||||
func generateToken(login config.Login, user, pass, otp, scopes string) (string, error) {
|
||||
func generateToken(ctx stdctx.Context, login config.Login, user, pass, otp, scopes string) (string, error) {
|
||||
opts := []gitea.ClientOption{gitea.SetBasicAuth(user, pass)}
|
||||
if otp != "" {
|
||||
opts = append(opts, gitea.SetOTP(otp))
|
||||
@@ -168,7 +169,7 @@ func generateToken(login config.Login, user, pass, otp, scopes string) (string,
|
||||
|
||||
var tl []*gitea.AccessToken
|
||||
for page := 1; ; {
|
||||
page_tokens, resp, err := client.ListAccessTokens(gitea.ListAccessTokensOptions{
|
||||
page_tokens, resp, err := client.Users.ListAccessTokens(ctx, gitea.ListAccessTokensOptions{
|
||||
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -200,7 +201,7 @@ func generateToken(login config.Login, user, pass, otp, scopes string) (string,
|
||||
}
|
||||
}
|
||||
|
||||
t, _, err := client.CreateAccessToken(gitea.CreateAccessTokenOption{
|
||||
t, _, err := client.Users.CreateAccessToken(ctx, gitea.CreateAccessTokenOption{
|
||||
Name: tokenName,
|
||||
Scopes: tokenScopes,
|
||||
})
|
||||
|
||||
@@ -8,9 +8,10 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
"gitea.dev/sdk"
|
||||
"golang.org/x/crypto/ssh"
|
||||
|
||||
"gitea.dev/tea/modules/utils"
|
||||
)
|
||||
|
||||
// ListSSHPubkey lists all the ssh keys in the ssh agent and the ~/.ssh/*.pub files
|
||||
|
||||
@@ -4,24 +4,25 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"encoding/base64"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/tea/modules/utils"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
// findSSHKey retrieves the ssh keys registered in gitea, and tries to find
|
||||
// a matching private key in ~/.ssh/. If no match is found, path is empty.
|
||||
func findSSHKey(client *gitea.Client) (string, error) {
|
||||
func findSSHKey(ctx stdctx.Context, client *gitea.Client) (string, error) {
|
||||
// get keys registered on gitea instance
|
||||
var keys []*gitea.PublicKey
|
||||
for page := 1; ; {
|
||||
page_keys, resp, err := client.ListMyPublicKeys(gitea.ListPublicKeysOptions{
|
||||
page_keys, resp, err := client.Users.ListMyPublicKeys(ctx, gitea.ListPublicKeysOptions{
|
||||
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -4,23 +4,24 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/tea/modules/config"
|
||||
"gitea.dev/tea/modules/print"
|
||||
)
|
||||
|
||||
// CreateMilestone creates a milestone in the given repo and prints the result
|
||||
func CreateMilestone(login *config.Login, repoOwner, repoName, title, description string, deadline *time.Time, state gitea.StateType) error {
|
||||
func CreateMilestone(ctx stdctx.Context, login *config.Login, repoOwner, repoName, title, description string, deadline *time.Time, state gitea.StateType) error {
|
||||
// title is required
|
||||
if len(title) == 0 {
|
||||
return fmt.Errorf("title is required")
|
||||
}
|
||||
|
||||
mile, _, err := login.Client().CreateMilestone(repoOwner, repoName, gitea.CreateMilestoneOption{
|
||||
mile, _, err := login.Client().Repositories.CreateMilestone(ctx, repoOwner, repoName, gitea.CreateMilestoneOption{
|
||||
Title: title,
|
||||
Description: description,
|
||||
Deadline: deadline,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -11,17 +12,16 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
local_git "code.gitea.io/tea/modules/git"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
git_plumbing "github.com/go-git/go-git/v5/plumbing"
|
||||
"gitea.dev/tea/modules/config"
|
||||
local_git "gitea.dev/tea/modules/git"
|
||||
"gitea.dev/tea/modules/utils"
|
||||
)
|
||||
|
||||
// PullCheckout checkout current workdir to the head branch of specified pull request
|
||||
func PullCheckout(
|
||||
ctx stdctx.Context,
|
||||
login *config.Login,
|
||||
repoOwner, repoName string,
|
||||
forceCreateBranch bool,
|
||||
@@ -29,7 +29,7 @@ func PullCheckout(
|
||||
callback func(string) (string, error),
|
||||
) error {
|
||||
client := login.Client()
|
||||
pr, _, err := client.GetPullRequest(repoOwner, repoName, index)
|
||||
pr, _, err := client.PullRequests.GetPullRequest(ctx, repoOwner, repoName, index)
|
||||
if err != nil {
|
||||
return fmt.Errorf("couldn't fetch PR: %s", err)
|
||||
}
|
||||
@@ -80,7 +80,7 @@ func doPRFetch(
|
||||
login *config.Login,
|
||||
pr *gitea.PullRequest,
|
||||
localRepo *local_git.TeaRepo,
|
||||
localRemote *git.Remote,
|
||||
localRemote *local_git.Remote,
|
||||
callback func(string) (string, error),
|
||||
) (string, error) {
|
||||
_ = callback
|
||||
@@ -90,6 +90,10 @@ func doPRFetch(
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
auth, err := local_git.GetAuthForURL(url, login.GetAccessToken(), login.SSHKey, callback)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
refspecs := []string{}
|
||||
if isRemoteDeleted(pr) {
|
||||
// When the head branch is already deleted, pr.Head.Ref points to
|
||||
@@ -97,15 +101,15 @@ func doPRFetch(
|
||||
// This ref must be fetched explicitly, and does not allow pushing, so we use it
|
||||
// only in this case as fallback.
|
||||
localBranchName = fmt.Sprintf("pulls/%d", pr.Index)
|
||||
refspecs = append(refspecs, fmt.Sprintf("%s:refs/remotes/%s/%s",
|
||||
refspecs = []string{fmt.Sprintf("%s:refs/remotes/%s/%s",
|
||||
pr.Head.Ref,
|
||||
localRemoteName,
|
||||
localBranchName,
|
||||
))
|
||||
)}
|
||||
}
|
||||
fmt.Printf("Fetching PR %v (head %s:%s) from remote '%s'\n", pr.Index, url, pr.Head.Ref, localRemoteName)
|
||||
|
||||
err = runGitFetch(localRemoteName, url.String(), login.GetAccessToken(), login.SSHKey, refspecs...)
|
||||
err = localRepo.Fetch(localRemoteName, refspecs, auth)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -122,12 +126,12 @@ func doPRCheckout(
|
||||
) error {
|
||||
// determine the ref to checkout, depending on existence of a matching commit on a local branch
|
||||
var info string
|
||||
var checkoutRef git_plumbing.ReferenceName
|
||||
var checkoutRef local_git.ReferenceName
|
||||
|
||||
if b, _ := localRepo.TeaFindBranchBySha(pr.Head.Sha, remoteURL); b != nil {
|
||||
|
||||
// if a matching branch exists, use that
|
||||
checkoutRef = git_plumbing.NewBranchReferenceName(b.Name)
|
||||
checkoutRef = local_git.NewBranchReferenceName(b.Name)
|
||||
info = fmt.Sprintf("Found matching local branch %s, checking it out", checkoutRef.Short())
|
||||
|
||||
} else if forceCreateBranch {
|
||||
@@ -137,10 +141,10 @@ func doPRCheckout(
|
||||
if isRemoteDeleted(pr) {
|
||||
localBranchName += "-" + pr.Head.Ref
|
||||
}
|
||||
checkoutRef = git_plumbing.NewBranchReferenceName(localBranchName)
|
||||
checkoutRef = local_git.NewBranchReferenceName(localBranchName)
|
||||
if err := localRepo.TeaCreateBranch(localBranchName, localRemoteBranchName, localRemoteName); err == nil {
|
||||
info = fmt.Sprintf("Created branch '%s'\n", localBranchName)
|
||||
} else if err == git.ErrBranchExists {
|
||||
} else if err == local_git.ErrBranchExists {
|
||||
info = "There may be changes since you last checked out, run `git pull` to get them."
|
||||
} else {
|
||||
return err
|
||||
@@ -149,7 +153,7 @@ func doPRCheckout(
|
||||
} else {
|
||||
|
||||
// use the remote tracking branch
|
||||
checkoutRef = git_plumbing.NewRemoteReferenceName(localRemoteName, localRemoteBranchName)
|
||||
checkoutRef = local_git.NewRemoteReferenceName(localRemoteName, localRemoteBranchName)
|
||||
info = fmt.Sprintf(
|
||||
"Checking out remote tracking branch %s. To make changes, create a new branch:\n git checkout %s",
|
||||
checkoutRef.String(), localRemoteBranchName)
|
||||
|
||||
@@ -4,21 +4,20 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/tea/modules/config"
|
||||
local_git "code.gitea.io/tea/modules/git"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
git_config "github.com/go-git/go-git/v5/config"
|
||||
git_plumbing "github.com/go-git/go-git/v5/plumbing"
|
||||
"gitea.dev/tea/modules/config"
|
||||
local_git "gitea.dev/tea/modules/git"
|
||||
)
|
||||
|
||||
// PullClean deletes local & remote feature-branches for a closed pull
|
||||
func PullClean(login *config.Login, repoOwner, repoName string, index int64, ignoreSHA bool, callback func(string) (string, error)) error {
|
||||
func PullClean(ctx stdctx.Context, login *config.Login, repoOwner, repoName string, index int64, ignoreSHA bool, callback func(string) (string, error)) error {
|
||||
client := login.Client()
|
||||
|
||||
repo, _, err := client.GetRepo(repoOwner, repoName)
|
||||
repo, _, err := client.Repositories.GetRepo(ctx, repoOwner, repoName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -28,7 +27,7 @@ func PullClean(login *config.Login, repoOwner, repoName string, index int64, ign
|
||||
}
|
||||
|
||||
// fetch PR source-repo & -branch from gitea
|
||||
pr, _, err := client.GetPullRequest(repoOwner, repoName, index)
|
||||
pr, _, err := client.PullRequests.GetPullRequest(ctx, repoOwner, repoName, index)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -51,7 +50,7 @@ func PullClean(login *config.Login, repoOwner, repoName string, index int64, ign
|
||||
}
|
||||
|
||||
// find a branch with matching sha or name, that has a remote matching the repo url
|
||||
var branch *git_config.Branch
|
||||
var branch *local_git.Branch
|
||||
if ignoreSHA {
|
||||
branch, err = r.TeaFindBranchByName(remoteBranch, pr.Head.Repository.CloneURL)
|
||||
} else {
|
||||
@@ -77,7 +76,7 @@ call me again with the --ignore-sha flag`, remoteBranch)
|
||||
}
|
||||
if headRef.Name().Short() == branch.Name {
|
||||
fmt.Printf("Checking out '%s' to delete local branch '%s'\n", defaultBranch, branch.Name)
|
||||
ref := git_plumbing.NewBranchReferenceName(defaultBranch)
|
||||
ref := local_git.NewBranchReferenceName(defaultBranch)
|
||||
if err = r.TeaCheckout(ref); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+16
-14
@@ -4,16 +4,18 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
local_git "code.gitea.io/tea/modules/git"
|
||||
"code.gitea.io/tea/modules/print"
|
||||
"code.gitea.io/tea/modules/utils"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/config"
|
||||
"gitea.dev/tea/modules/context"
|
||||
local_git "gitea.dev/tea/modules/git"
|
||||
"gitea.dev/tea/modules/print"
|
||||
"gitea.dev/tea/modules/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,10 +25,10 @@ var (
|
||||
)
|
||||
|
||||
// CreatePull creates a PR in the given repo and prints the result
|
||||
func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits *bool, opts *gitea.CreateIssueOption) (err error) {
|
||||
func CreatePull(requestCtx stdctx.Context, ctx *context.TeaContext, base, head string, allowMaintainerEdits *bool, opts *gitea.CreateIssueOption) (err error) {
|
||||
// default is default branch
|
||||
if len(base) == 0 {
|
||||
base, err = GetDefaultPRBase(ctx.Login, ctx.Owner, ctx.Repo)
|
||||
base, err = GetDefaultPRBase(requestCtx, ctx.Login, ctx.Owner, ctx.Repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -61,7 +63,7 @@ func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits
|
||||
|
||||
client := ctx.Login.Client()
|
||||
|
||||
pr, _, err := client.CreatePullRequest(ctx.Owner, ctx.Repo, gitea.CreatePullRequestOption{
|
||||
pr, _, err := client.PullRequests.CreatePullRequest(requestCtx, ctx.Owner, ctx.Repo, gitea.CreatePullRequestOption{
|
||||
Head: head,
|
||||
Base: base,
|
||||
Title: opts.Title,
|
||||
@@ -76,7 +78,7 @@ func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits
|
||||
}
|
||||
|
||||
if allowMaintainerEdits != nil && pr.AllowMaintainerEdit != *allowMaintainerEdits {
|
||||
pr, _, err = client.EditPullRequest(ctx.Owner, ctx.Repo, pr.Index, gitea.EditPullRequestOption{
|
||||
pr, _, err = client.PullRequests.EditPullRequest(requestCtx, ctx.Owner, ctx.Repo, pr.Index, gitea.EditPullRequestOption{
|
||||
AllowMaintainerEdit: allowMaintainerEdits,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -92,8 +94,8 @@ func CreatePull(ctx *context.TeaContext, base, head string, allowMaintainerEdits
|
||||
}
|
||||
|
||||
// GetDefaultPRBase retrieves the default base branch for the given repo
|
||||
func GetDefaultPRBase(login *config.Login, owner, repo string) (string, error) {
|
||||
meta, _, err := login.Client().GetRepo(owner, repo)
|
||||
func GetDefaultPRBase(requestCtx stdctx.Context, login *config.Login, owner, repo string) (string, error) {
|
||||
meta, _, err := login.Client().Repositories.GetRepo(requestCtx, owner, repo)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not fetch repo meta: %s", err)
|
||||
}
|
||||
@@ -155,13 +157,13 @@ func GetDefaultPRTitle(header string) string {
|
||||
}
|
||||
|
||||
// CreateAgitFlowPull creates a agit flow PR in the given repo and prints the result
|
||||
func CreateAgitFlowPull(ctx *context.TeaContext, remote, head, base, topic string,
|
||||
func CreateAgitFlowPull(requestCtx stdctx.Context, ctx *context.TeaContext, remote, head, base, topic string,
|
||||
opts *gitea.CreateIssueOption,
|
||||
callback func(string) (string, error),
|
||||
) (err error) {
|
||||
// default is default branch
|
||||
if len(base) == 0 {
|
||||
base, err = GetDefaultPRBase(ctx.Login, ctx.Owner, ctx.Repo)
|
||||
base, err = GetDefaultPRBase(requestCtx, ctx.Login, ctx.Owner, ctx.Repo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+11
-10
@@ -4,23 +4,24 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
gitea "gitea.dev/sdk"
|
||||
"gitea.dev/tea/modules/context"
|
||||
)
|
||||
|
||||
// EditPull edits a pull request and returns the updated pull request.
|
||||
func EditPull(ctx *context.TeaContext, client *gitea.Client, opts EditIssueOption) (*gitea.PullRequest, error) {
|
||||
func EditPull(requestCtx stdctx.Context, ctx *context.TeaContext, client *gitea.Client, opts EditIssueOption) (*gitea.PullRequest, error) {
|
||||
if client == nil {
|
||||
client = ctx.Login.Client()
|
||||
}
|
||||
|
||||
addLabelOpts, err := ResolveLabelOpts(client, ctx.Owner, ctx.Repo, opts.AddLabels)
|
||||
addLabelOpts, err := ResolveLabelOpts(requestCtx, client, ctx.Owner, ctx.Repo, opts.AddLabels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rmLabelOpts, err := ResolveLabelOpts(client, ctx.Owner, ctx.Repo, opts.RemoveLabels)
|
||||
rmLabelOpts, err := ResolveLabelOpts(requestCtx, client, ctx.Owner, ctx.Repo, opts.RemoveLabels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -36,7 +37,7 @@ func EditPull(ctx *context.TeaContext, client *gitea.Client, opts EditIssueOptio
|
||||
prOptsDirty = true
|
||||
}
|
||||
if opts.Milestone != nil {
|
||||
id, err := ResolveMilestoneID(client, ctx.Owner, ctx.Repo, *opts.Milestone)
|
||||
id, err := ResolveMilestoneID(requestCtx, client, ctx.Owner, ctx.Repo, *opts.Milestone)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -55,22 +56,22 @@ func EditPull(ctx *context.TeaContext, client *gitea.Client, opts EditIssueOptio
|
||||
prOptsDirty = true
|
||||
}
|
||||
|
||||
if err := ApplyLabelChanges(client, ctx.Owner, ctx.Repo, opts.Index, addLabelOpts, rmLabelOpts); err != nil {
|
||||
if err := ApplyLabelChanges(requestCtx, client, ctx.Owner, ctx.Repo, opts.Index, addLabelOpts, rmLabelOpts); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := ApplyReviewerChanges(client, ctx.Owner, ctx.Repo, opts.Index, opts.AddReviewers, opts.RemoveReviewers); err != nil {
|
||||
if err := ApplyReviewerChanges(requestCtx, client, ctx.Owner, ctx.Repo, opts.Index, opts.AddReviewers, opts.RemoveReviewers); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var pr *gitea.PullRequest
|
||||
if prOptsDirty {
|
||||
pr, _, err = client.EditPullRequest(ctx.Owner, ctx.Repo, opts.Index, prOpts)
|
||||
pr, _, err = client.PullRequests.EditPullRequest(requestCtx, ctx.Owner, ctx.Repo, opts.Index, prOpts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not edit pull request: %s", err)
|
||||
}
|
||||
} else {
|
||||
pr, _, err = client.GetPullRequest(ctx.Owner, ctx.Repo, opts.Index)
|
||||
pr, _, err = client.PullRequests.GetPullRequest(requestCtx, ctx.Owner, ctx.Repo, opts.Index)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get pull request: %s", err)
|
||||
}
|
||||
|
||||
@@ -4,16 +4,18 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/config"
|
||||
)
|
||||
|
||||
// PullMerge merges a PR
|
||||
func PullMerge(login *config.Login, repoOwner, repoName string, index int64, opt gitea.MergePullRequestOption) error {
|
||||
func PullMerge(requestCtx stdctx.Context, login *config.Login, repoOwner, repoName string, index int64, opt gitea.MergePullRequestOption) error {
|
||||
client := login.Client()
|
||||
success, _, err := client.MergePullRequest(repoOwner, repoName, index, opt)
|
||||
success, _, err := client.PullRequests.MergePullRequest(requestCtx, repoOwner, repoName, index, opt)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -4,15 +4,16 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/tea/modules/context"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
unidiff "gitea.com/noerw/unidiff-comments"
|
||||
"gitea.dev/tea/modules/context"
|
||||
)
|
||||
|
||||
var diffReviewHelp = `# This is the current diff of PR #%d on %s.
|
||||
@@ -28,10 +29,10 @@ var diffReviewHelp = `# This is the current diff of PR #%d on %s.
|
||||
`
|
||||
|
||||
// CreatePullReview submits a review for a PR
|
||||
func CreatePullReview(ctx *context.TeaContext, idx int64, status gitea.ReviewStateType, comment string, codeComments []gitea.CreatePullReviewComment) error {
|
||||
func CreatePullReview(requestCtx stdctx.Context, ctx *context.TeaContext, idx int64, status gitea.ReviewStateType, comment string, codeComments []gitea.CreatePullReviewComment) error {
|
||||
c := ctx.Login.Client()
|
||||
|
||||
review, _, err := c.CreatePullReview(ctx.Owner, ctx.Repo, idx, gitea.CreatePullReviewOptions{
|
||||
review, _, err := c.PullRequests.CreatePullReview(requestCtx, ctx.Owner, ctx.Repo, idx, gitea.CreatePullReviewOptions{
|
||||
State: status,
|
||||
Body: comment,
|
||||
Comments: codeComments,
|
||||
@@ -46,8 +47,8 @@ func CreatePullReview(ctx *context.TeaContext, idx int64, status gitea.ReviewSta
|
||||
|
||||
// SavePullDiff fetches the diff of a pull request and stores it as a temporary file.
|
||||
// The path to the file is returned.
|
||||
func SavePullDiff(ctx *context.TeaContext, idx int64) (string, error) {
|
||||
diff, _, err := ctx.Login.Client().GetPullRequestDiff(ctx.Owner, ctx.Repo, idx, gitea.PullRequestDiffOptions{})
|
||||
func SavePullDiff(requestCtx stdctx.Context, ctx *context.TeaContext, idx int64) (string, error) {
|
||||
diff, _, err := ctx.Login.Client().PullRequests.GetPullRequestDiff(requestCtx, ctx.Owner, ctx.Repo, idx, gitea.PullRequestDiffOptions{})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -4,19 +4,21 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
stdctx "context"
|
||||
"fmt"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/context"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/modules/context"
|
||||
)
|
||||
|
||||
// ListPullReviewComments lists all review comments across all reviews for a PR
|
||||
func ListPullReviewComments(ctx *context.TeaContext, idx int64) ([]*gitea.PullReviewComment, error) {
|
||||
func ListPullReviewComments(requestCtx stdctx.Context, ctx *context.TeaContext, idx int64) ([]*gitea.PullReviewComment, error) {
|
||||
c := ctx.Login.Client()
|
||||
|
||||
var reviews []*gitea.PullReview
|
||||
for page := 1; ; {
|
||||
page_reviews, resp, err := c.ListPullReviews(ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
||||
page_reviews, resp, err := c.PullRequests.ListPullReviews(requestCtx, ctx.Owner, ctx.Repo, idx, gitea.ListPullReviewsOptions{
|
||||
ListOptions: gitea.ListOptions{Page: page, PageSize: 50},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -31,7 +33,7 @@ func ListPullReviewComments(ctx *context.TeaContext, idx int64) ([]*gitea.PullRe
|
||||
|
||||
var allComments []*gitea.PullReviewComment
|
||||
for _, review := range reviews {
|
||||
comments, _, err := c.ListPullReviewComments(ctx.Owner, ctx.Repo, idx, review.ID)
|
||||
comments, _, err := c.PullRequests.ListPullReviewComments(requestCtx, ctx.Owner, ctx.Repo, idx, review.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -42,10 +44,10 @@ func ListPullReviewComments(ctx *context.TeaContext, idx int64) ([]*gitea.PullRe
|
||||
}
|
||||
|
||||
// ResolvePullReviewComment resolves a review comment
|
||||
func ResolvePullReviewComment(ctx *context.TeaContext, commentID int64) error {
|
||||
func ResolvePullReviewComment(requestCtx stdctx.Context, ctx *context.TeaContext, commentID int64) error {
|
||||
c := ctx.Login.Client()
|
||||
|
||||
_, err := c.ResolvePullReviewComment(ctx.Owner, ctx.Repo, commentID)
|
||||
_, err := c.PullRequests.ResolvePullReviewComment(requestCtx, ctx.Owner, ctx.Repo, commentID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -55,10 +57,10 @@ func ResolvePullReviewComment(ctx *context.TeaContext, commentID int64) error {
|
||||
}
|
||||
|
||||
// ReplyToPullReviewComment replies to a review comment on a pull request.
|
||||
func ReplyToPullReviewComment(ctx *context.TeaContext, idx, commentID int64, body string) error {
|
||||
func ReplyToPullReviewComment(requestCtx stdctx.Context, ctx *context.TeaContext, idx, commentID int64, body string) error {
|
||||
c := ctx.Login.Client()
|
||||
|
||||
comment, _, err := c.CreatePullReviewCommentReply(ctx.Owner, ctx.Repo, idx, commentID, gitea.CreatePullReviewCommentReplyOptions{
|
||||
comment, _, err := c.PullRequests.CreatePullReviewCommentReply(requestCtx, ctx.Owner, ctx.Repo, idx, commentID, gitea.CreatePullReviewCommentReplyOptions{
|
||||
Body: body,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -70,10 +72,10 @@ func ReplyToPullReviewComment(ctx *context.TeaContext, idx, commentID int64, bod
|
||||
}
|
||||
|
||||
// UnresolvePullReviewComment unresolves a review comment
|
||||
func UnresolvePullReviewComment(ctx *context.TeaContext, commentID int64) error {
|
||||
func UnresolvePullReviewComment(requestCtx stdctx.Context, ctx *context.TeaContext, commentID int64) error {
|
||||
c := ctx.Login.Client()
|
||||
|
||||
_, err := c.UnresolvePullReviewComment(ctx.Owner, ctx.Repo, commentID)
|
||||
_, err := c.PullRequests.UnresolvePullReviewComment(requestCtx, ctx.Owner, ctx.Repo, commentID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+10
-30
@@ -4,28 +4,26 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
stdctx "context"
|
||||
"net/url"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"code.gitea.io/tea/modules/config"
|
||||
local_git "code.gitea.io/tea/modules/git"
|
||||
gitea "gitea.dev/sdk"
|
||||
|
||||
"github.com/go-git/go-git/v5"
|
||||
git_config "github.com/go-git/go-git/v5/config"
|
||||
"github.com/go-git/go-git/v5/plumbing"
|
||||
"gitea.dev/tea/modules/config"
|
||||
local_git "gitea.dev/tea/modules/git"
|
||||
)
|
||||
|
||||
// RepoClone creates a local git clone in the given path, and sets up upstream remote
|
||||
// for fork repos, for good usability with tea.
|
||||
func RepoClone(
|
||||
ctx stdctx.Context,
|
||||
path string,
|
||||
login *config.Login,
|
||||
repoOwner, repoName string,
|
||||
callback func(string) (string, error),
|
||||
depth int,
|
||||
) (*local_git.TeaRepo, error) {
|
||||
repoMeta, _, err := login.Client().GetRepo(repoOwner, repoName)
|
||||
repoMeta, _, err := login.Client().Repositories.GetRepo(ctx, repoOwner, repoName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,12 +43,7 @@ func RepoClone(
|
||||
path = repoName
|
||||
}
|
||||
|
||||
repo, err := git.PlainClone(path, false, &git.CloneOptions{
|
||||
URL: originURL.String(),
|
||||
Auth: auth,
|
||||
Depth: depth,
|
||||
InsecureSkipTLS: login.Insecure,
|
||||
})
|
||||
repo, err := local_git.Clone(path, originURL.String(), auth, depth, login.Insecure)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -62,28 +55,15 @@ func RepoClone(
|
||||
return nil, err
|
||||
}
|
||||
upstreamBranch := repoMeta.Parent.DefaultBranch
|
||||
_, err = repo.CreateRemote(&git_config.RemoteConfig{
|
||||
Name: "upstream",
|
||||
URLs: []string{upstreamURL.String()},
|
||||
})
|
||||
if err != nil {
|
||||
if err = repo.AddRemote("upstream", upstreamURL.String()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
repoConf, err := repo.Config()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if b, ok := repoConf.Branches[upstreamBranch]; ok {
|
||||
b.Remote = "upstream"
|
||||
b.Merge = plumbing.ReferenceName(fmt.Sprintf("refs/heads/%s", upstreamBranch))
|
||||
}
|
||||
if err = repo.SetConfig(repoConf); err != nil {
|
||||
if err = repo.SetBranchUpstream(upstreamBranch, "upstream", upstreamBranch); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return &local_git.TeaRepo{Repository: repo}, nil
|
||||
return repo, nil
|
||||
}
|
||||
|
||||
func cloneURL(repo *gitea.Repository, login *config.Login) (*url.URL, error) {
|
||||
|
||||
Reference in New Issue
Block a user