Skip to content

Commit

Permalink
source org not needed when passing repo list
Browse files Browse the repository at this point in the history
  • Loading branch information
amenocal committed Jul 23, 2024
1 parent c3b63f4 commit 700fd04
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var syncCmd = &cobra.Command{
ghHostname := cmd.Flag("source-hostname").Value.String()
repository := cmd.Flag("repository").Value.String()
mappingFile := cmd.Flag("mapping-file").Value.String()
repositoryList := cmd.Flag("repository-list").Value.String()
repositoryList := cmd.Flag("repository-list-file").Value.String()

// Set ENV variables
os.Setenv("GHMT_SOURCE_ORGANIZATION", sourceOrganization)
Expand Down Expand Up @@ -57,7 +57,6 @@ func init() {

// Flags
syncCmd.Flags().StringP("source-organization", "s", "", "Source Organization to sync releases from")
syncCmd.MarkFlagRequired("source-organization")

syncCmd.Flags().StringP("target-organization", "t", "", "Target Organization to sync releases from")
syncCmd.MarkFlagRequired("target-organization")
Expand Down
2 changes: 1 addition & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func GetSourceRepositoryReleases(owner string, repository string) ([]*github.Rep
for {
releases, resp, err := client.Repositories.ListReleases(ctx, owner, repository, opts)
if err != nil {
return allReleases, fmt.Errorf("error getting releases: %v", err)
return allReleases, fmt.Errorf("unable to get releases: %v", err)
}
allReleases = append(allReleases, releases...)
if resp.NextPage == 0 {
Expand Down
5 changes: 4 additions & 1 deletion pkg/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ func checkVars() {
if viper.GetString("REPOSITORY") != "" && viper.GetString("REPOSITORY_LIST") != "" {
pterm.Error.Println("Error: Cannot specify both a repository and a repository list")
os.Exit(1)
} else if viper.GetString("REPOSITORY") != "" && viper.GetString("SOURCE_ORGANIZATION") == "" {
pterm.Error.Println("Error: Source organization is required when specifying a repository")
os.Exit(1)
}
}

Expand All @@ -102,7 +105,7 @@ func migrateRepositoryReleases(repository string) (int, int, error) {
fetchReleasesSpinner, _ := pterm.DefaultSpinner.Start("Fetching releases from repository: ", repository)
releases, err := api.GetSourceRepositoryReleases(owner, repository)
if err != nil {
pterm.Error.Printf("Error getting releases: %v", err)
pterm.Fatal.Printf("Error: %v", err)
fetchReleasesSpinner.Fail()
}
fetchReleasesSpinner.UpdateText(fmt.Sprintf(" %d Releases fetched successfully!", len(releases)))
Expand Down

0 comments on commit 700fd04

Please sign in to comment.