downstream

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DownstreamCmd = &cobra.Command{
	Use:   "downstream",
	Short: "Ports a GitHub Pull Request from an upstream OSS repository to a downstream fork",
	RunE: func(cmd *cobra.Command, args []string) error {
		err := checkPersistenFlags()
		if len(branch) == 0 {
			branch = fmt.Sprintf("%s-downstream-%s-pr-%d", utils.ProjectName, head, prNumUpstream)
		}
		if len(repo) == 0 {
			err = multierror.Append(fmt.Errorf("must define fork repository"), err)
		}
		if prNumUpstream == 0 {
			err = multierror.Append(fmt.Errorf("must define a pull request number to be downstreamed"), err)
		}
		if len(head) == 0 {
			err = multierror.Append(fmt.Errorf("must define fork's head ref"), err)
		}
		if err != nil {
			return err
		}

		upstreamOrg, upstreamRepoName, err := getOrgRepo(repoUpstream)
		if err != nil {
			return err
		}

		forkOrg, forkRepoName, err := getOrgRepo(repo)
		if err != nil {
			return err
		}

		ctx := context.Background()
		git := utils.NewGitHelper()
		client := utils.GetGithubClient()
		return downstream.Downstream(ctx, git, client, &downstream.DownstreamRequest{
			Branch:                 branch,
			UpstreamOrg:            upstreamOrg,
			UpstreamRepo:           upstreamRepoName,
			UpstreamHeadRef:        headUpstream,
			UpstreamPullRequestNum: int(prNumUpstream),
			ForkOrg:                forkOrg,
			ForkRepo:               forkRepoName,
			ForkHeadRef:            head,
			PreserveTempBranches:   preserveTempBranches,
			PushAndOpenPullRequest: !noPush,
		})
	},
}
View Source
var DownstreamSuggestCmd = &cobra.Command{
	Use:   "suggest",
	Short: "Suggests a list of GitHub Pull Requests to be downstreamed",
	RunE: func(cmd *cobra.Command, args []string) error {
		err := checkPersistenFlags()
		if err != nil {
			return err
		}

		searchAfterTs, err := time.Parse(time.RFC3339, searchAfter)
		if err != nil {
			return err
		}

		upstreamOrg, upstreamRepoName, err := getOrgRepo(repoUpstream)
		if err != nil {
			return err
		}

		ctx := context.Background()
		git := utils.NewGitHelper()
		client := utils.GetGithubClient()
		return downstream.Suggest(ctx, git, client, &downstream.SuggestRequest{
			UpstreamOrg:     upstreamOrg,
			UpstreamRepo:    upstreamRepoName,
			UpstreamHeadRef: headUpstream,
			ForkHeadRef:     head,
			SearchAfter:     searchAfterTs,
		})
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL