Skip to content

PROTOTYPE: feat(init): git init features - #1149

Draft
bepri wants to merge 3 commits into
mainfrom
work/init-git-features/CRAFT-5060
Draft

PROTOTYPE: feat(init): git init features#1149
bepri wants to merge 3 commits into
mainfrom
work/init-git-features/CRAFT-5060

Conversation

@bepri

@bepri bepri commented Aug 3, 2026

Copy link
Copy Markdown
Member
  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run make lint && make test?
  • Have you added an entry to the changelog (docs/reference/changelog.rst)?

A prototype to add Git features to the init command.

CRAFT-5060

Copilot AI review requested due to automatic review settings August 3, 2026 20:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR prototypes VCS (Git) support for the init command by adding a --vcs flag, initializing a Git repository during project initialization, and extending Testcraft to customize generated .gitignore entries.

Changes:

  • Add --vcs {git,none} to craft_application’s init command and run VCS setup during initialization.
  • Rename GitRepo._init_repo() to GitRepo.init_repo() and update unit tests accordingly.
  • Add Testcraft InitCommand override plus unit/spread tests covering VCS behavior.

Reviewed changes

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

Show a summary per file
File Description
tests/unit/services/test_remotebuild.py Updates mocks/assertions for the init_repo rename.
tests/unit/git/test_git.py Updates patch targets from _init_repo to init_repo.
tests/unit/commands/test_init.py Adds vcs arg coverage and new tests for VCS initialization and .gitignore creation.
tests/spread/testcraft/init-vcs/task.yaml Adds spread test coverage for Testcraft init with/without VCS.
testcraft/commands/init.py Introduces Testcraft-specific InitCommand overriding vcs_ignore_globs.
testcraft/commands/init.py Exports the new InitCommand.
testcraft/cli.py Registers Testcraft InitCommand (overriding default init).
craft_application/git/_git_repo.py Renames repository initialization method to init_repo.
craft_application/commands/init.py Implements --vcs flag, VCS initialization, and .gitignore appending logic.

Comment thread craft_application/commands/init.py Outdated
Comment thread craft_application/commands/init.py
Comment thread tests/spread/testcraft/init-vcs/task.yaml Outdated
@bepri
bepri requested review from lengau and steinbro August 10, 2026 18:39
return sorted([template.name for template in template_dirs])

@property
def vcs_ignore_globs(self) -> list[str]:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The intention here was to create an easy way to customize what entries appear in a generated gitignore. For example, if Snapcraft overrides this to return ["*.snap", "*.comp"], it would add this to a gitignore file:

# Added by Snapcraft
*.snap
*.comp

parser.add_argument(
"--vcs",
type=str,
choices=["git", "none"],

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This copies how uv handles it, which is certainly future-proof, but I'm considering doing --no-vcs as an opt-out flag and removing --vcs as a flag since I doubt we'll support anything other than git any time soon.

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