Add flag for skipping git initialization to init command (#1122)

This commit is contained in:
Micah
2025-10-07 17:12:22 -07:00
committed by GitHub
parent 6ea95d487c
commit beb497878b
2 changed files with 12 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
## Unreleased
* Added flag to `rojo init` to skip initializing a git repository ([#1122])
* Added fallback method for when an Instance can't be synced through normal means ([#1030])
This should make it possible to sync `MeshParts` and `Unions`!
@@ -19,6 +20,7 @@
* Added `--absolute` flag to the sourcemap subcommand, which will emit absolute paths instead of relative paths. ([#1092])
* Fixed applying `gameId` and `placeId` before initial sync was accepted ([#1104])
[#1122]: https://github.com/rojo-rbx/rojo/pull/1122
[#1030]: https://github.com/rojo-rbx/rojo/pull/1030
[#1096]: https://github.com/rojo-rbx/rojo/pull/1096
[#1093]: https://github.com/rojo-rbx/rojo/pull/1093

View File

@@ -22,15 +22,22 @@ const GIT_IGNORE_PLACEHOLDER: &str = "gitignore.txt";
static TEMPLATE_BINCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/templates.bincode"));
/// Initializes a new Rojo project.
///
/// By default, this will attempt to initialize a 'git' repository in the
/// project directory if `git` is installed. To avoid this, pass `--skip-git`.
#[derive(Debug, Parser)]
pub struct InitCommand {
/// Path to the place to create the project. Defaults to the current directory.
#[clap(default_value = "")]
pub path: PathBuf,
/// The kind of project to create, 'place', 'plugin', or 'model'. Defaults to place.
/// The kind of project to create, 'place', 'plugin', or 'model'.
#[clap(long, default_value = "place")]
pub kind: InitKind,
/// Skips the initialization of a git repository.
#[clap(long)]
pub skip_git: bool,
}
impl InitCommand {
@@ -73,7 +80,7 @@ impl InitCommand {
} else {
let content = vfs.read_to_string_lf_normalized(&path)?;
if let Some(file_stem) = path.file_name().and_then(OsStr::to_str) {
if file_stem == GIT_IGNORE_PLACEHOLDER {
if file_stem == GIT_IGNORE_PLACEHOLDER && !self.skip_git {
path.set_file_name(".gitignore");
}
}
@@ -84,7 +91,7 @@ impl InitCommand {
}
}
if should_git_init(&base_path) {
if !self.skip_git && should_git_init(&base_path) {
log::debug!("Initializing Git repository...");
let status = Command::new("git")