Skip to content

Commit

Permalink
centralize the git support stuff into a single option.
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandervoord committed Apr 13, 2024
1 parent acd7356 commit 519fc34
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
<br/>
Expand Down
2 changes: 1 addition & 1 deletion bin/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions bin/cli_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions spec/spec_system_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/system/deployment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 519fc34

Please sign in to comment.