-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathnumber_of_files_committed.rb
52 lines (40 loc) · 1.1 KB
/
number_of_files_committed.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
difficulty 1
description "There are some files in this repository; how many of them are staged for a commit?"
setup do
repo.init
# Modified files
%w{rubyfile4.rb rubyfile5.rb}.each do |file|
FileUtils.touch(file)
repo.add(file)
system "git branch -m master"
end
repo.commit_all "Commit"
# Staged file
File.open("rubyfile4.rb", 'w') { |f| f << "#Changes" }
repo.add("rubyfile4.rb")
# Not staged file
File.open("rubyfile5.rb", 'w') { |f| f << "#Changes" }
# Changes to be committed
%w{rubyfile1.rb}.each do |file|
FileUtils.touch(file)
repo.add(file)
end
# Untracked files
%w{rubyfile6.rb rubyfile7.rb}.each do |file|
FileUtils.touch(file)
end
end
solution do
numberOfFilesThereWillBeCommit = request("How many files are going to be committed?")
isInteger = !!(numberOfFilesThereWillBeCommit =~ /^[-+]?[0-9]+$/)
if !isInteger
return false
end
if numberOfFilesThereWillBeCommit.to_i == 2
return true
end
return false
end
hint do
puts "You are looking for a command to identify the status of the repository (resembles a Linux command)."
end