Skip to content

feat: add repository migration helper#58

Draft
ehennestad wants to merge 3 commits into
mainfrom
codex/repo-migration-function
Draft

feat: add repository migration helper#58
ehennestad wants to merge 3 commits into
mainfrom
codex/repo-migration-function

Conversation

@ehennestad
Copy link
Copy Markdown
Owner

Summary

Adds a MatBox repository migration helper for converting existing MATLAB repositories to the src/tests/tools layout used by MatBox-compatible toolbox repositories.

Details

  • Adds matbox.repo.migrateToMatBoxRepo with dry-run planning by default.
  • Uses git mv for source moves when the target repository is under git.
  • Generates MatBox toolbox metadata and tool helpers without namespacing existing source code.
  • Copies workflow and helper templates from a Matlab-Toolbox template repository.
  • Adds focused migration tests for dry-run behavior, layout creation, overwrite protection, requirements preservation, git moves, and .gitignore spacing.

@ehennestad ehennestad requested a review from Copilot May 21, 2026 10:09
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a new repository migration utility to convert an existing MATLAB repo into the MatBox-compatible src/, tests/, tools/ layout, along with a focused unit test suite to validate core migration behaviors.

Changes:

  • Introduces matbox.repo.migrateToMatBoxRepo with dry-run planning, overwrite protection, .gitignore merging, and template-based scaffolding.
  • Adds unit tests covering dry-run non-modification, layout creation, destination protection, requirements preservation, and git-aware moves.
  • Adds minimal template-repo scaffolding in tests to exercise workflow and helper copying.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
code/+matbox/+repo/migrateToMatBoxRepo.m New migration helper that plans/applies filesystem and template operations to create a MatBox-style repository layout.
tools/tests/+matboxtools/+unittest/RepoMigrationTest.m New unit tests validating key migration behaviors (dry-run, layout creation, protections, git move behavior).

Comment on lines +226 to +231
runSystemCommand("git", ["-C", repoRoot, "mv", source, destination])
else
movefile(source, destination)
end
end

Comment on lines +416 to +427
[sourceParent, ~] = fileparts(operations.Destination(index));
[~, packageName] = fileparts(sourceParent);
namespace = extractAfter(string(packageName), "+");

text = strrep(text, "{{ cookiecutter.namespace_name }}", "{{cookiecutter.namespace_name}}");
text = strrep(text, "{{ cookiecutter.toolbox_name }}", "{{cookiecutter.toolbox_name}}");
text = strrep(text, "{{ cookiecutter.namespace_name | upper}}", "{{cookiecutter.namespace_name | upper}}");
text = strrep(text, "{{cookiecutter.namespace_name}}", char(namespace));
text = strrep(text, "{{cookiecutter.namespace_name | upper}}", char(upper(namespace)));
text = strrep(text, "{{cookiecutter.toolbox_name}}", char(namespace));
end

Comment on lines +139 to +143
if options.CreateNamespaceUtilities
namespacePackageFolder = fullfile(repoRoot, "src", options.SourceFolder, "+" + options.Namespace);
operations = addOperation(operations, "mkdir", "", namespacePackageFolder, "", ...
"Create source namespace utilities folder");
operations = addOperation(operations, "copy-render", templateFile(options.TemplateRepo, ...
end

function writeTextFile(filePath, text)
fid = fopen(filePath, "w");
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.

2 participants