From 519fc34e12e3ab45188acd60358da930b2909e32 Mon Sep 17 00:00:00 2001 From: Mark VanderVoord Date: Fri, 12 Apr 2024 21:10:56 -0400 Subject: [PATCH] centralize the git support stuff into a single option. --- README.md | 6 ++++-- bin/cli.rb | 2 +- bin/cli_handler.rb | 8 +++++--- spec/spec_system_helper.rb | 4 ++-- spec/system/deployment_spec.rb | 6 +++--- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 15d084dd..898a3b4c 100644 --- a/README.md +++ b/README.md @@ -450,10 +450,12 @@ can prevent Ceedling from updating your project file by adding ## Git integration Are you using Git? You might want Ceedling to create a `.gitignore` -file for you by adding `--gitignore` to your `new` call. +which ignores the build folder (while retaining control of the artifacts +folder). This will also add a `.gitkeep` file to your `test/support` folder. +You can enable this by adding `--gitsupport` to your `new` call. ```shell - > ceedling new --gitignore YourNewProjectName + > ceedling new --gitsupport YourNewProjectName ```
diff --git a/bin/cli.rb b/bin/cli.rb index a24622bf..c7fadcf6 100755 --- a/bin/cli.rb +++ b/bin/cli.rb @@ -163,7 +163,7 @@ def help(command=nil) method_option :configs, :type => :boolean, :default => true, :desc => "Install starter configuration files" method_option :force, :type => :boolean, :default => false, :desc => "Ignore any existing project and recreate destination" method_option :debug, :type => :boolean, :default => false, :hide => true - method_option :gitignore, :type => :boolean, :default => false, :desc => "Create a gitignore file for ignoring ceedling generated files" + method_option :gitsupport, :type => :boolean, :default => false, :desc => "Create .gitignore / .gitkeep files for convenience" long_desc <<-LONGDESC `ceedling new` creates a new project structure. diff --git a/bin/cli_handler.rb b/bin/cli_handler.rb index a7df5f86..5213c9d1 100755 --- a/bin/cli_handler.rb +++ b/bin/cli_handler.rb @@ -74,7 +74,6 @@ def new_project(ceedling_root, options, name, dest) ['.', 'src', 'test', 'test/support'].each do |path| @actions._empty_directory( File.join( dest, path) ) end - @actions._touch_file( File.join(dest, 'test/support', '.gitkeep') ) # Vendor the tools and install command line helper scripts @helper.vendor_tools( ceedling_root, dest ) if options[:local] @@ -86,8 +85,11 @@ def new_project(ceedling_root, options, name, dest) @helper.create_project_file( ceedling_root, dest, options[:local] ) if options[:configs] # Copy Git Ignore file - @actions._copy_file( File.join(ceedling_root,'assets','default_gitignore'), File.join(dest,'.gitignore'), :force => true ) if options[:gitignore] - + if options[:gitsupport] + @actions._copy_file( File.join(ceedling_root,'assets','default_gitignore'), File.join(dest,'.gitignore'), :force => true ) + @actions._touch_file( File.join(dest, 'test/support', '.gitkeep') ) + end + @logger.log( "\n🌱 New project '#{name}' created at #{dest}/\n" ) end diff --git a/spec/spec_system_helper.rb b/spec/spec_system_helper.rb index 2ddaf79f..71722248 100644 --- a/spec/spec_system_helper.rb +++ b/spec/spec_system_helper.rb @@ -173,15 +173,15 @@ def can_create_projects expect(File.exist?("src")).to eq true expect(File.exist?("test")).to eq true expect(File.exist?("test/support")).to eq true - expect(File.exist?("test/support/.gitkeep")).to eq true end end end - def has_an_ignore + def has_git_support @c.with_context do Dir.chdir @proj_name do expect(File.exist?(".gitignore")).to eq true + expect(File.exist?("test/support/.gitkeep")).to eq true end end end diff --git a/spec/system/deployment_spec.rb b/spec/system/deployment_spec.rb index cf859de9..6f297bf4 100644 --- a/spec/system/deployment_spec.rb +++ b/spec/system/deployment_spec.rb @@ -54,15 +54,15 @@ it { run_all_test_when_test_case_name_is_passed_but_cmdline_args_are_disabled_with_success } end - describe "deployed in a project's `vendor` directory with gitignore." do + describe "deployed in a project's `vendor` directory with git support." do before do @c.with_context do - `bundle exec ruby -S ceedling new --local --docs --gitignore #{@proj_name} 2>&1` + `bundle exec ruby -S ceedling new --local --docs --gitsupport #{@proj_name} 2>&1` end end it { can_create_projects } - it { has_an_ignore } + it { has_git_support } it { contains_a_vendor_directory } it { contains_documentation } it { can_test_projects_with_success }