Skip to content

Commit 6ac01ae

Browse files
authored
Merge pull request #64 from github/git-url
Add a hidden push option for specifying the destination Git URL
2 parents 55fba50 + cf7bdeb commit 6ac01ae

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

cmd/push.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var pushCmd = &cobra.Command{
1616
RunE: func(cmd *cobra.Command, args []string) error {
1717
version.LogVersion()
1818
cacheDirectory := cachedirectory.NewCacheDirectory(rootFlags.cacheDir)
19-
return push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH)
19+
return push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH, pushFlags.gitURL)
2020
},
2121
}
2222

@@ -27,6 +27,7 @@ type pushFlagFields struct {
2727
actionsAdminUser string
2828
force bool
2929
pushSSH bool
30+
gitURL string
3031
}
3132

3233
var pushFlags = pushFlagFields{}
@@ -45,4 +46,6 @@ func (f *pushFlagFields) Init(cmd *cobra.Command) {
4546
cmd.Flags().StringVar(&f.actionsAdminUser, "actions-admin-user", "actions-admin", "The name of the Actions admin user.")
4647
cmd.Flags().BoolVar(&f.force, "force", false, "Replace the existing repository even if it was not created by the sync tool.")
4748
cmd.Flags().BoolVar(&f.pushSSH, "push-ssh", false, "Push Git contents over SSH rather than HTTPS. To use this option you must have SSH access to your GitHub Enterprise instance configured.")
49+
cmd.Flags().StringVar(&f.gitURL, "git-url", "", "Use a custom Git URL for pushing the Action repository contents to.")
50+
cmd.Flags().MarkHidden("git-url")
4851
}

cmd/sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var syncCmd = &cobra.Command{
1818
if err != nil {
1919
return err
2020
}
21-
err = push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH)
21+
err = push.Push(cmd.Context(), cacheDirectory, pushFlags.destinationURL, pushFlags.destinationToken, pushFlags.destinationRepository, pushFlags.actionsAdminUser, pushFlags.force, pushFlags.pushSSH, pushFlags.gitURL)
2222
if err != nil {
2323
return err
2424
}

internal/push/push.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ type pushService struct {
5353
aegis bool
5454
force bool
5555
pushSSH bool
56+
gitURL string
5657
}
5758

5859
func (pushService *pushService) createRepository() (*github.Repository, error) {
@@ -163,9 +164,12 @@ func (pushService *pushService) createRepository() (*github.Repository, error) {
163164
}
164165

165166
func (pushService *pushService) pushGit(repository *github.Repository, initialPush bool) error {
166-
remoteURL := repository.GetCloneURL()
167-
if pushService.pushSSH {
168-
remoteURL = repository.GetSSHURL()
167+
remoteURL := pushService.gitURL
168+
if remoteURL == "" {
169+
remoteURL = repository.GetCloneURL()
170+
if pushService.pushSSH {
171+
remoteURL = repository.GetSSHURL()
172+
}
169173
}
170174
if initialPush {
171175
log.Debugf("Pushing Git releases to %s...", remoteURL)
@@ -375,7 +379,7 @@ func (pushService *pushService) pushReleases() error {
375379
return nil
376380
}
377381

378-
func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, destinationURL string, destinationToken string, destinationRepository string, actionsAdminUser string, force bool, pushSSH bool) error {
382+
func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, destinationURL string, destinationToken string, destinationRepository string, actionsAdminUser string, force bool, pushSSH bool, gitURL string) error {
379383
err := cacheDirectory.CheckOrCreateVersionFile(false, version.Version())
380384
if err != nil {
381385
return err
@@ -433,6 +437,7 @@ func Push(ctx context.Context, cacheDirectory cachedirectory.CacheDirectory, des
433437
aegis: aegis,
434438
force: force,
435439
pushSSH: pushSSH,
440+
gitURL: gitURL,
436441
}
437442

438443
repository, err := pushService.createRepository()

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