Skip to content

Commit 515aa34

Browse files
authored
Merge pull request #110 from akaihola/copy-description
Transfer repository description by default
2 parents 840100f + 0c73c23 commit 515aa34

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
@@ -31,6 +31,7 @@ export default {
3131
useLowerCaseLabels: true,
3232
},
3333
transfer: {
34+
description: true,
3435
milestones: true,
3536
labels: true,
3637
issues: true,

src/githubHelper.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,20 @@ export class GithubHelper {
292292
(author.username === settings.github.token_owner));
293293
}
294294

295+
/**
296+
* Update the description of the repository on GitHub.
297+
* Replaces newlines and tabs with spaces. No attempt is made to remove e.g. Markdown
298+
* links or other special formatting.
299+
*/
300+
async updateRepositoryDescription(description) {
301+
let props : RestEndpointMethodTypes["repos"]["update"]["parameters"] = {
302+
owner: this.githubOwner,
303+
repo: this.githubRepo,
304+
description: description.replace(/\s+/g, " ")
305+
}
306+
return this.githubApi.repos.update(props);
307+
}
308+
295309
/**
296310
* TODO description
297311
* @param milestones All GitHub milestones

src/index.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ async function migrate() {
151151
await githubHelper.registerRepoId();
152152
await gitlabHelper.registerProjectPath(settings.gitlab.projectId);
153153

154+
// transfer GitLab description to GitHub
155+
if (settings.transfer.description) {
156+
await transferDescription();
157+
}
158+
154159
// transfer GitLab milestones to GitHub
155160
if (settings.transfer.milestones) {
156161
await transferMilestones();
@@ -190,6 +195,22 @@ async function migrate() {
190195

191196
// ----------------------------------------------------------------------------
192197

198+
/**
199+
* Transfer the description of the repository.
200+
*/
201+
async function transferDescription() {
202+
inform('Transferring Description');
203+
204+
// Get the description of this project
205+
let project = await gitlabApi.Projects.show(
206+
settings.gitlab.projectId
207+
) as any;
208+
209+
await githubHelper.updateRepositoryDescription(project.description);
210+
}
211+
212+
// ----------------------------------------------------------------------------
213+
193214
/**
194215
* Transfer any milestones that exist in GitLab that do not exist in GitHub.
195216
*/

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)