Skip to content

Commit 2fd1503

Browse files
committed
Merge branch 'master' into feature/126-milestone-references
2 parents a3deab3 + 515aa34 commit 2fd1503

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

sample_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export default {
3232
useLowerCaseLabels: true,
3333
},
3434
transfer: {
35+
description: true,
3536
milestones: true,
3637
labels: true,
3738
issues: true,

src/githubHelper.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,20 @@ export class GithubHelper {
308308
);
309309
}
310310

311+
/**
312+
* Update the description of the repository on GitHub.
313+
* Replaces newlines and tabs with spaces. No attempt is made to remove e.g. Markdown
314+
* links or other special formatting.
315+
*/
316+
async updateRepositoryDescription(description) {
317+
let props : RestEndpointMethodTypes["repos"]["update"]["parameters"] = {
318+
owner: this.githubOwner,
319+
repo: this.githubRepo,
320+
description: description.replace(/\s+/g, " ")
321+
}
322+
return this.githubApi.repos.update(props);
323+
}
324+
311325
/**
312326
* TODO description
313327
* @param milestones All GitHub milestones

src/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,10 @@ async function migrate() {
171171
await githubHelper.registerRepoId();
172172
await gitlabHelper.registerProjectPath(settings.gitlab.projectId);
173173

174+
if (settings.transfer.description) {
175+
await transferDescription();
176+
}
177+
174178
if (settings.transfer.milestones) {
175179
await transferMilestones(
176180
settings.usePlaceholderMilestonesForMissingMilestones
@@ -207,6 +211,22 @@ async function migrate() {
207211

208212
// ----------------------------------------------------------------------------
209213

214+
/**
215+
* Transfer the description of the repository.
216+
*/
217+
async function transferDescription() {
218+
inform('Transferring Description');
219+
220+
// Get the description of this project
221+
let project = await gitlabApi.Projects.show(
222+
settings.gitlab.projectId
223+
) as any;
224+
225+
await githubHelper.updateRepositoryDescription(project.description);
226+
}
227+
228+
// ----------------------------------------------------------------------------
229+
210230
/**
211231
* Transfer any milestones that exist in GitLab that do not exist in GitHub.
212232
*/

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)