Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update skuba managed sections when merging ignore files #58

Merged
merged 10 commits into from
Jun 17, 2020

Conversation

lumishrestha
Copy link
Contributor

Added skuba managed section to ignore files in the base template. So,skuba configure can update those sections without overwriting any existing files.

@lumishrestha lumishrestha requested a review from a team as a code owner June 16, 2020 01:54
@changeset-bot
Copy link

changeset-bot bot commented Jun 16, 2020

🦋 Changeset is good to go

Latest commit: cb7a8cb

We got this.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

template/base/_.gitignore Outdated Show resolved Hide resolved
(line) => !templateSet.has(line),
const replacedSkubaSection = inputFile?.replace(
/# managed by skuba[\s\S]*# end managed by skuba/,
'',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do the replacement inline here?

How about inverting this to be more like:

if (typeof inputFile === 'undefined') {
  return templateFile;
}

return inputFile.replace('...', templateFile);

You could even one-liner it, but we might add some extra hacks in here later to make the migration less jarring.

Copy link
Member

@72636c 72636c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, the snapshots are looking good.

src/cli/configure/processing/ignoreFile.ts Outdated Show resolved Hide resolved
Comment on lines 8 to 15
if (inputFile.includes('# managed by skuba')) {
const replacedSkubaSection = inputFile.replace(
/# managed by skuba[\s\S]*# end managed by skuba/,
templateFile,
);

const inputLines = splitIntoSanitisedLines(inputFile ?? '').filter(
(line) => !templateSet.has(line),
);
return `${replacedSkubaSection}`;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about:

const replacedFile = inputFile.replace(/.../, templateFile);

if (replacedFile.includes(templateFile)) {
  return replacedFile;
}

It's probably overly-paranoid, but it avoids mismatches between the .replace pattern and .includes string

@72636c 72636c mentioned this pull request Jun 16, 2020
11 tasks
@lumishrestha lumishrestha merged commit 72c2e2c into master Jun 17, 2020
@lumishrestha lumishrestha deleted the section-ignore-file branch June 17, 2020 00:21
72636c added a commit that referenced this pull request Jun 22, 2020
This should leave repos migrated from `seek-module-toolkit` and pre-#58
ignore files in a better state instead of littering old patterns
everywhere.
72636c added a commit that referenced this pull request Jun 22, 2020
This should leave repos migrated from `seek-module-toolkit` and pre-#58
ignore files in a better state instead of littering old patterns
everywhere.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants