sync

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SyncCmd = &cobra.Command{
	Use:   "sync",
	Short: "Syncs the fork to an upstream ref by appending all the custom commits",
	RunE: func(cmd *cobra.Command, args []string) error {
		var err error
		if len(syncRepoUpstream) == 0 {
			err = multierror.Append(fmt.Errorf("must define upstream repository in scan request"), err)
		}
		if len(syncRepo) == 0 {
			err = multierror.Append(fmt.Errorf("must define fork's repository in scan request"), err)
		}
		if len(syncHeadUpstream) == 0 {
			err = multierror.Append(fmt.Errorf("must define upstream head ref in scan request"), err)
		}
		if len(syncHead) == 0 {
			err = multierror.Append(fmt.Errorf("must define fork's head ref in scan request"), err)
		}
		if len(syncBranch) == 0 {
			err = multierror.Append(fmt.Errorf("must define name of the sync branch in fork"), err)
		}
		if err != nil {
			return err
		}

		forkOrg, syncRepoName, err := getOrgRepo(syncRepo)
		if err != nil {
			return err
		}
		upstreamOrg, upstreamRepoName, err := getOrgRepo(syncRepoUpstream)
		if err != nil {
			return err
		}

		ctx := context.Background()
		client := utils.GetGithubClient()
		return sync.Sync(
			ctx,
			utils.NewGitHelper(),
			client,
			&sync.Request{
				DryRun:          syncDryRun,
				OutBranch:       syncBranch,
				UpstreamOrg:     upstreamOrg,
				UpstreamRepo:    upstreamRepoName,
				ForkOrg:         forkOrg,
				ForkRepo:        syncRepoName,
				ForkHeadRef:     syncHead,
				UpstreamHeadRef: syncHeadUpstream,
			},
		)
	},
}

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