Skip to content

Commit

Permalink
Merge pull request #83 from timrogers/timrogers/project-title
Browse files Browse the repository at this point in the history
feat: add support for overriding the title of the imported project
  • Loading branch information
timrogers authored Nov 22, 2023
2 parents 13e4770 + 3c00332 commit d89512b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ gh migrate-project import \
--base-url https://github.acme.inc/api/v3 \
# OPTIONAL: The URL of an HTTP(S) proxy to use for requests to the GitHub API (e.g. `http://localhost:3128`). This can also be set using the IMPORT_PROXY_URL environment variable.
--proxy-url https://10.0.0.1:3128 \
# OPTIONAL: The title to use for the imported project. Defaults to the title of the source project.
--project-title "My Imported Project" \
# OPTIONAL: Emit detailed, verbose logs (off by default)
--verbose
```
Expand Down
14 changes: 11 additions & 3 deletions src/commands/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@ interface Arguments {
accessToken?: string;
baseUrl: string;
inputPath: string;
repositoryMappingsPath: string;
projectOwner: string;
projectOwnerType: ProjectOwnerType;
projectTitle?: string;
proxyUrl: string | undefined;
repositoryMappingsPath: string;
verbose: boolean;
}

Expand Down Expand Up @@ -691,6 +692,10 @@ command
'--repository-mappings-path <repository_mappings_path>',
'The path to your completed repository mappings file. This will be the --repository-mappings-output-path argument passed to the `export` command, which defaults to `repository-mappings.csv`.',
)
.option(
'--project-title <project_name>',
'The title to use for the imported project. Defaults to the title of the source project.',
)
.requiredOption(
'--project-owner <project_owner>',
'The organization or user which should own the imported project',
Expand All @@ -717,6 +722,7 @@ command
inputPath,
projectOwner,
projectOwnerType,
projectTitle,
proxyUrl,
repositoryMappingsPath,
verbose,
Expand Down Expand Up @@ -788,12 +794,14 @@ command
`Successfully looked up ID for ${projectOwnerType} ${projectOwner}: ${ownerId}`,
);

const title = projectTitle || sourceProject.title;

const { id: targetProjectId, url: targetProjectUrl } = await createProject({
octokit,
ownerId,
title: sourceProject.title,
title,
});
logger.info(`Created project "${sourceProject.title}" with ID ${targetProjectId}`);
logger.info(`Created project "${title}" with ID ${targetProjectId}`);

const sourceProjectRepositoriesCount = sourceProject.repositories.nodes.length;

Expand Down

0 comments on commit d89512b

Please sign in to comment.