Sha256: c2d649ba79708704ed5a1a76af419e322dedeba17039a6a3829702049101d872

Contents?: true

Size: 883 Bytes

Versions: 5

Compression:

Stored size: 883 Bytes

Contents

# -*- encoding : utf-8 -*-
difficulty 2
description "Java编译后会创建 `.class` 文件和 `target` 文件夹, 这些文件/夹并不需要放到代码库中,请配置Git忽略它们。"

setup do
  repo.init

  FileUtils.touch("Hello.class")

  cwd = Dir.pwd
  target = Dir.mkdir "target"
  Dir.chdir "target"
  FileUtils.touch("Foo.class")
  Dir.chdir cwd

  file = File.open(".git/config", "w") do |file|
    file.puts "[core]\nexcludesfile="
  end
end

solution do
  classValid = false
  targetValid = false


  File.open(".gitignore", "r") do |file|
    while line = file.gets
      if line.chomp == "*.class"
        classValid = true
      end

      if line.chomp == "target" || line.chomp == "target/"
        targetValid = true
      end
    end
  end

  classValid && targetValid
end

hint do
  puts "在.gitignore中先加class文件,再加target文件夹"
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mygithug-0.5.6 levels/ignore.rb
mygithug-0.5.5 levels/ignore.rb
mygithug-0.5.4 levels/ignore.rb
mygithug-0.5.3 levels/ignore.rb
mygithug-0.5.2 levels/ignore.rb