Skip to content

Commit 0c73c23

Browse files
committed
Transfer repository description by default
Reads GitHub project description, removes newlines and tabs, and updates the GitHub repository description. This can be disabled by setting the `transfer.description` setting to `false`.
1 parent 7572017 commit 0c73c23

4 files changed

Lines changed: 37 additions & 0 deletions

File tree

sample_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
useLowerCaseLabels: true,
3030
},
3131
transfer: {
32+
description: true,
3233
milestones: true,
3334
labels: true,
3435
issues: true,

src/githubHelper.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,20 @@ export default class GithubHelper {
205205
******************************************************************************
206206
*/
207207

208+
/**
209+
* Update the description of the repository on GitHub.
210+
* Replaces newlines and tabs with spaces. No attempt is made to remove e.g. Markdown
211+
* links or other special formatting.
212+
*/
213+
async updateRepositoryDescription(description) {
214+
let props : RestEndpointMethodTypes["repos"]["update"]["parameters"] = {
215+
owner: this.githubOwner,
216+
repo: this.githubRepo,
217+
description: description.replace(/\s+/g, " ")
218+
}
219+
return this.githubApi.repos.update(props);
220+
}
221+
208222
/**
209223
* TODO description
210224
*/

src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ async function migrate() {
127127

128128
await githubHelper.registerRepoId();
129129

130+
// transfer GitLab description to GitHub
131+
if (settings.transfer.description) {
132+
await transferDescription();
133+
}
134+
130135
// transfer GitLab milestones to GitHub
131136
if (settings.transfer.milestones) {
132137
await transferMilestones();
@@ -159,6 +164,22 @@ async function migrate() {
159164

160165
// ----------------------------------------------------------------------------
161166

167+
/**
168+
* Transfer the description of the repository.
169+
*/
170+
async function transferDescription() {
171+
inform('Transferring Description');
172+
173+
// Get the description of this project
174+
let project = await gitlabApi.Projects.show(
175+
settings.gitlab.projectId
176+
) as any;
177+
178+
await githubHelper.updateRepositoryDescription(project.description);
179+
}
180+
181+
// ----------------------------------------------------------------------------
182+
162183
/**
163184
* Transfer any milestones that exist in GitLab that do not exist in GitHub.
164185
*/

src/settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default interface Settings {
1212
useLowerCaseLabels: boolean;
1313
};
1414
transfer: {
15+
description: boolean;
1516
milestones: boolean;
1617
labels: boolean;
1718
issues: boolean;

0 commit comments

Comments
 (0)