Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ var pullCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
version.LogVersion()
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
return pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken)
return pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken, pullFlags.sourceURL)
},
}

type pullFlagFields struct {
sourceToken string
sourceURL string
}

var pullFlags = pullFlagFields{}

func (f *pullFlagFields) Init(cmd *cobra.Command) {
cmd.Flags().StringVar(&f.sourceToken, "source-token", "", "A token to access the API of GitHub.com. This is normally not required, but can be provided if you have issues with API rate limiting.")
cmd.Flags().StringVar(&f.sourceURL, "source-url", "", "Use a custom Git URL for fetching the Action repository contents from. The CodeQL bundles will still be fetched from GitHub.com.")
cmd.Flags().MarkHidden("source-url")
}
2 changes: 1 addition & 1 deletion cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var syncCmd = &cobra.Command{
RunE: func(cmd *cobra.Command, args []string) error {
version.LogVersion()
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
err := pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken)
err := pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken, pullFlags.sourceURL)
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions internal/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

const sourceOwner = "github"
const sourceRepository = "codeql-action"
const sourceURL = "https://github.com/" + sourceOwner + "/" + sourceRepository + ".git"
const defaultSourceURL = "https://github.com/" + sourceOwner + "/" + sourceRepository + ".git"

var relevantReferences = regexp.MustCompile("^refs/(heads|tags)/(main|v\\d+)$")

Expand Down Expand Up @@ -254,7 +254,7 @@ func (pullService *pullService) pullReleases() error {
return nil
}

func Pull(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, sourceToken string) error {
func Pull(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, sourceToken string, sourceURL string) error {
err := cacheDirectory.CheckOrCreateVersionFile(true, version.Version())
if err != nil {
return err
Expand All @@ -272,6 +272,10 @@ func Pull(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, sou
tokenClient = oauth2.NewClient(ctx, tokenSource)
}

if sourceURL == "" {
sourceURL = defaultSourceURL
}

pullService := pullService{
ctx: ctx,
cacheDirectory: cacheDirectory,
Expand Down