Skip to content

Commit 06cf2d3

Browse files
authored
Merge pull request #62 from github/source-url-flag
Add a hidden flag to fetch from an alternative Git source.
2 parents 1890f26 + 1e04ff2 commit 06cf2d3

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

cmd/pull.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ var pullCmd = &cobra.Command{
1313
RunE: func(cmd *cobra.Command, args []string) error {
1414
version.LogVersion()
1515
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
16-
return pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken)
16+
return pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken, pullFlags.sourceURL)
1717
},
1818
}
1919

2020
type pullFlagFields struct {
2121
sourceToken string
22+
sourceURL string
2223
}
2324

2425
var pullFlags = pullFlagFields{}
2526

2627
func (f *pullFlagFields) Init(cmd *cobra.Command) {
2728
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.")
29+
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.")
30+
cmd.Flags().MarkHidden("source-url")
2831
}

cmd/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var syncCmd = &cobra.Command{
1414
RunE: func(cmd *cobra.Command, args []string) error {
1515
version.LogVersion()
1616
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
17-
err := pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken)
17+
err := pull.Pull(cmd.Context(), cacheDirectory, pullFlags.sourceToken, pullFlags.sourceURL)
1818
if err != nil {
1919
return err
2020
}

internal/pull/pull.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import (
2929

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

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

@@ -254,7 +254,7 @@ func (pullService *pullService) pullReleases() error {
254254
return nil
255255
}
256256

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

275+
if sourceURL == "" {
276+
sourceURL = defaultSourceURL
277+
}
278+
275279
pullService := pullService{
276280
ctx: ctx,
277281
cacheDirectory: cacheDirectory,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy