gitit 0.7.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/dictionaries/pat.xml +19 -0
- data/VERSION +1 -1
- data/lib/gitit/command_branch.rb +3 -4
- data/lib/gitit/command_branches.rb +24 -20
- data/lib/gitit/command_config.rb +21 -19
- data/lib/gitit/command_executor.rb +3 -4
- data/lib/gitit/command_status.rb +12 -15
- data/lib/gitit/git.rb +7 -7
- data/lib/gitit/repo.rb +6 -7
- data/lib/gitit/version.rb +1 -1
- data/lib/gitit.rb +2 -2
- data/spec/gitit_branch_spec.rb +5 -5
- data/spec/gitit_branches_spec.rb +41 -36
- data/spec/gitit_config_spec.rb +64 -41
- data/spec/gitit_spec.rb +19 -19
- data/spec/gitit_status_spec.rb +37 -37
- data/spec/spec_helper.rb +15 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23fb8d00f8124e0bf2b40c92e825473c3382f0bb
|
4
|
+
data.tar.gz: 77d0f01adadb44f35b3d6754135d21a586afc492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2b95bf891d1d1dbd989d64fdf74f064b886edb47f5a9b99f995d6da912fd3d68bb9b410ace57205e0a05e1484dd820e636675073cec07178833a54e234910a2
|
7
|
+
data.tar.gz: 3d86fd55e764cbcc4e471ebec1d0c2e06b461c8803c63953471587ee482d0abeda9ee0574820c24e0a18f54dc5e1954812d0d6a2593c1b70c0c925ed09e03c26
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<component name="ProjectDictionaryState">
|
2
|
+
<dictionary name="pat">
|
3
|
+
<words>
|
4
|
+
<w>adsdsadasdsa</w>
|
5
|
+
<w>badorigin</w>
|
6
|
+
<w>bdssdsoo</w>
|
7
|
+
<w>dsaadk</w>
|
8
|
+
<w>gitit</w>
|
9
|
+
<w>mybranch</w>
|
10
|
+
<w>mytestkey</w>
|
11
|
+
<w>uncommit</w>
|
12
|
+
<w>uncommited</w>
|
13
|
+
<w>unstage</w>
|
14
|
+
<w>unstaged</w>
|
15
|
+
<w>untracked</w>
|
16
|
+
<w>withsub</w>
|
17
|
+
</words>
|
18
|
+
</dictionary>
|
19
|
+
</component>
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/lib/gitit/command_branch.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'gitit/command_executor'
|
2
2
|
|
3
3
|
module Gitit
|
4
4
|
|
@@ -19,9 +19,8 @@ module Gitit
|
|
19
19
|
# -------------------------------------------------------------------------
|
20
20
|
# -------------------------------------------------------------------------
|
21
21
|
def valid?
|
22
|
-
|
23
|
-
|
24
|
-
return false
|
22
|
+
execute_command('diff --cached --no-ext-diff --ignore-submodules --quiet --exit-code')
|
23
|
+
$?.exitstatus == 1
|
25
24
|
end
|
26
25
|
|
27
26
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'gitit/command_executor'
|
2
2
|
|
3
3
|
module Gitit
|
4
4
|
|
@@ -15,42 +15,46 @@ module Gitit
|
|
15
15
|
|
16
16
|
# -------------------------------------------------------------------------
|
17
17
|
# -------------------------------------------------------------------------
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def get_current_branch
|
19
|
+
branches = execute_command('branch --no-color')
|
20
|
+
branch_match = branches.each_line.select { |b| b.start_with? '* ' }
|
21
|
+
branch_match[0].strip.gsub(/\* /, '')
|
22
|
+
end
|
23
|
+
|
24
|
+
# -------------------------------------------------------------------------
|
25
|
+
# -------------------------------------------------------------------------
|
26
|
+
def exists_locally?(name)
|
27
|
+
execute_command("branch --no-color | sed 's/^[* ] //' | grep #{name}")
|
28
|
+
$?.exitstatus == 0
|
22
29
|
end
|
23
30
|
|
24
31
|
# -------------------------------------------------------------------------
|
25
32
|
# -------------------------------------------------------------------------
|
26
|
-
def
|
27
|
-
|
28
|
-
|
29
|
-
return false
|
33
|
+
def exists_remotely?(name, remote)
|
34
|
+
execute_command("branch -r --no-color | sed 's/^[* ] //' | grep #{remote}/#{name}")
|
35
|
+
$?.exitstatus == 0
|
30
36
|
end
|
31
37
|
|
32
38
|
# -------------------------------------------------------------------------
|
33
39
|
# -------------------------------------------------------------------------
|
34
|
-
def
|
35
|
-
|
36
|
-
|
37
|
-
return false
|
40
|
+
def create_local_branch(name)
|
41
|
+
execute_command("branch --quiet #{name}")
|
42
|
+
$?.exitstatus == 0
|
38
43
|
end
|
39
44
|
|
40
45
|
# -------------------------------------------------------------------------
|
41
46
|
# -------------------------------------------------------------------------
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
return false
|
47
|
+
def push_local_branch_to_remote(name, remote, force)
|
48
|
+
execute_command("push --quiet -f #{remote} #{name}") if force
|
49
|
+
execute_command("push --quiet #{remote} #{name}") unless force
|
50
|
+
$?.exitstatus == 0
|
47
51
|
end
|
48
52
|
|
49
53
|
# -------------------------------------------------------------------------
|
50
54
|
# -------------------------------------------------------------------------
|
51
|
-
def
|
55
|
+
#def update_from_remote(branch_name, remote)
|
52
56
|
|
53
|
-
end
|
57
|
+
#end
|
54
58
|
|
55
59
|
end
|
56
60
|
|
data/lib/gitit/command_config.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'gitit/command_executor'
|
2
2
|
|
3
3
|
module Gitit
|
4
4
|
|
@@ -9,45 +9,47 @@ module Gitit
|
|
9
9
|
|
10
10
|
# -------------------------------------------------------------------------
|
11
11
|
# -------------------------------------------------------------------------
|
12
|
-
def initialize(repo)
|
12
|
+
def initialize(repo, location='')
|
13
13
|
@repo = repo
|
14
|
+
@location = location
|
14
15
|
end
|
15
16
|
|
16
17
|
# -------------------------------------------------------------------------
|
17
18
|
# -------------------------------------------------------------------------
|
18
|
-
def
|
19
|
-
value =
|
20
|
-
raise
|
21
|
-
value
|
22
|
-
return value
|
19
|
+
def get_value(key)
|
20
|
+
value = execute_command("config #{@location} --null --get #{key}")
|
21
|
+
raise 'failure running command' if $?.exitstatus != 0
|
22
|
+
value.slice!(0, value.length-1)
|
23
23
|
end
|
24
24
|
|
25
25
|
# -------------------------------------------------------------------------
|
26
26
|
# -------------------------------------------------------------------------
|
27
|
-
def
|
27
|
+
def set_value(key, value)
|
28
28
|
val = value
|
29
|
-
|
30
|
-
raise
|
29
|
+
execute_command("config #{@location} \"#{key}\" \"#{val}\"")
|
30
|
+
raise 'failure running command' if $?.exitstatus != 0
|
31
31
|
end
|
32
32
|
|
33
33
|
# -------------------------------------------------------------------------
|
34
34
|
# -------------------------------------------------------------------------
|
35
|
-
def
|
36
|
-
|
37
|
-
raise
|
38
|
-
value = value.slice!(0, value.length-1)
|
39
|
-
return value
|
35
|
+
def unset_value(key)
|
36
|
+
execute_command("config #{@location} --null --unset #{key}")
|
37
|
+
raise 'failure running command' if $?.exitstatus != 0
|
40
38
|
end
|
41
39
|
|
42
40
|
# -------------------------------------------------------------------------
|
43
41
|
# -------------------------------------------------------------------------
|
44
|
-
def
|
45
|
-
|
46
|
-
|
47
|
-
raise "failure running command" if $?.exitstatus != 0
|
42
|
+
def remove_section(section)
|
43
|
+
execute_command("config #{@location} --remove-section #{section}")
|
44
|
+
raise 'failure running command' if $?.exitstatus != 0
|
48
45
|
end
|
49
46
|
|
50
47
|
end
|
51
48
|
|
49
|
+
class LocalConfig
|
50
|
+
end
|
51
|
+
|
52
|
+
class GlobalConfig
|
53
|
+
end
|
52
54
|
|
53
55
|
end
|
@@ -5,10 +5,9 @@ module Gitit
|
|
5
5
|
|
6
6
|
attr_reader :repo
|
7
7
|
|
8
|
-
def
|
9
|
-
gitCommand = [
|
10
|
-
|
11
|
-
return result
|
8
|
+
def execute_command(command)
|
9
|
+
gitCommand = ['git', command].join(' ')
|
10
|
+
`(cd #{@repo.location} && #{gitCommand} 2>&1)`
|
12
11
|
end
|
13
12
|
|
14
13
|
end
|
data/lib/gitit/command_status.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'gitit/command_executor'
|
2
2
|
|
3
3
|
module Gitit
|
4
4
|
|
@@ -16,35 +16,32 @@ module Gitit
|
|
16
16
|
# -------------------------------------------------------------------------
|
17
17
|
# -------------------------------------------------------------------------
|
18
18
|
def clean?
|
19
|
-
|
19
|
+
!unstaged_files? && !uncommited_files? && !untracked_files?
|
20
20
|
end
|
21
21
|
|
22
22
|
# -------------------------------------------------------------------------
|
23
23
|
# -------------------------------------------------------------------------
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
return false
|
24
|
+
def unstaged_files?
|
25
|
+
execute_command('diff-files --name-status --diff-filter=M --exit-code')
|
26
|
+
$?.exitstatus == 1
|
28
27
|
end
|
29
28
|
|
30
29
|
# -------------------------------------------------------------------------
|
31
30
|
# -------------------------------------------------------------------------
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
return false
|
31
|
+
def uncommited_files?
|
32
|
+
execute_command('diff --cached --no-ext-diff --ignore-submodules --quiet --exit-code')
|
33
|
+
$?.exitstatus == 1
|
36
34
|
end
|
37
35
|
|
38
36
|
# -------------------------------------------------------------------------
|
39
37
|
# -------------------------------------------------------------------------
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
return false
|
38
|
+
def untracked_files?
|
39
|
+
execute_command('status --porcelain | grep ??')
|
40
|
+
$?.exitstatus == 0
|
44
41
|
end
|
45
42
|
|
46
43
|
end
|
47
44
|
|
48
|
-
|
49
45
|
end
|
50
46
|
|
47
|
+
|
data/lib/gitit/git.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'gitit'
|
2
|
+
require 'gitit/repo'
|
3
3
|
|
4
|
-
Dir[File.dirname(__FILE__) +
|
4
|
+
Dir[File.dirname(__FILE__) + '/command_*.rb'].each do |file|
|
5
5
|
require file
|
6
6
|
end
|
7
7
|
|
@@ -10,10 +10,10 @@ module Gitit
|
|
10
10
|
# ---------------------------------------------------------------------------
|
11
11
|
# ---------------------------------------------------------------------------
|
12
12
|
class Git
|
13
|
-
attr_reader :repo
|
14
|
-
attr_reader :config
|
15
|
-
attr_reader :status
|
16
|
-
attr_reader :branches
|
13
|
+
attr_reader :repo
|
14
|
+
attr_reader :config
|
15
|
+
attr_reader :status
|
16
|
+
attr_reader :branches
|
17
17
|
|
18
18
|
# -------------------------------------------------------------------------
|
19
19
|
# -------------------------------------------------------------------------
|
data/lib/gitit/repo.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require 'gitit'
|
2
2
|
|
3
3
|
module Gitit
|
4
4
|
|
@@ -10,23 +10,22 @@ module Gitit
|
|
10
10
|
# -------------------------------------------------------------------------
|
11
11
|
# -------------------------------------------------------------------------
|
12
12
|
def initialize(location)
|
13
|
-
raise
|
13
|
+
raise 'Invalid path specified' unless File.directory? location
|
14
14
|
@location = location
|
15
15
|
end
|
16
16
|
|
17
17
|
# -------------------------------------------------------------------------
|
18
18
|
# -------------------------------------------------------------------------
|
19
19
|
def valid?
|
20
|
-
|
21
|
-
|
22
|
-
return false
|
20
|
+
`(cd #{@location} && git rev-parse --git-dir >/dev/null 2>&1)`
|
21
|
+
$?.exitstatus == 0
|
23
22
|
end
|
24
23
|
|
25
24
|
# -------------------------------------------------------------------------
|
26
25
|
# -------------------------------------------------------------------------
|
27
26
|
def init
|
28
|
-
raise
|
29
|
-
|
27
|
+
raise 'already a git repo' if valid?
|
28
|
+
`(cd #{@location} && git init)`
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
data/lib/gitit/version.rb
CHANGED
data/lib/gitit.rb
CHANGED
data/spec/gitit_branch_spec.rb
CHANGED
@@ -6,17 +6,17 @@ module Gitit
|
|
6
6
|
|
7
7
|
# -------------------------------------------------------------------------
|
8
8
|
# -------------------------------------------------------------------------
|
9
|
-
describe
|
9
|
+
describe '#test_repo_branch' do
|
10
10
|
|
11
11
|
before(:each) do
|
12
12
|
FileUtils.mkpath TEST_REPO_PATH
|
13
13
|
git = Git.new(TEST_REPO_PATH)
|
14
|
-
@
|
15
|
-
@
|
16
|
-
@repoBranch = Gitit::Branch.new(@
|
14
|
+
@my_repo = git.repo
|
15
|
+
@my_repo.init
|
16
|
+
@repoBranch = Gitit::Branch.new(@my_repo, 'master')
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'will tell us if the branch is a valid branch' do
|
20
20
|
end
|
21
21
|
|
22
22
|
after(:each) do
|
data/spec/gitit_branches_spec.rb
CHANGED
@@ -6,13 +6,13 @@ module Gitit
|
|
6
6
|
|
7
7
|
# -------------------------------------------------------------------------
|
8
8
|
# -------------------------------------------------------------------------
|
9
|
-
describe
|
9
|
+
describe '#test_branches_existance' do
|
10
10
|
|
11
11
|
before(:each) do
|
12
12
|
FileUtils.mkpath TEST_REPO_PATH
|
13
13
|
git = Git.new(TEST_REPO_PATH)
|
14
|
-
@
|
15
|
-
@
|
14
|
+
@my_repo = git.repo
|
15
|
+
@my_repo.init
|
16
16
|
@repoBranches = git.branches
|
17
17
|
|
18
18
|
`(cd #{TEST_REPO_PATH} && git config user.email "you@example.com")`
|
@@ -27,20 +27,25 @@ module Gitit
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
-
it
|
31
|
-
@repoBranches.
|
30
|
+
it 'will successfully find a valid local branch' do
|
31
|
+
@repoBranches.exists_locally?('master').should eq true
|
32
32
|
end
|
33
33
|
|
34
|
-
it
|
35
|
-
@repoBranches.
|
34
|
+
it 'will fail to find an invalid local branch' do
|
35
|
+
@repoBranches.exists_locally?('some_random_name').should eq false
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
39
|
-
@repoBranches.
|
38
|
+
it 'will successfully find a valid remote branch' do
|
39
|
+
@repoBranches.exists_remotely?('master', 'origin').should eq true
|
40
40
|
end
|
41
41
|
|
42
|
-
it
|
43
|
-
@repoBranches.
|
42
|
+
it 'will fail to find an invalid remote branch' do
|
43
|
+
@repoBranches.exists_remotely?('some_random_name', 'origin').should eq false
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'will successfully return the right branch name' do
|
47
|
+
`(cd #{TEST_REPO_PATH} && git checkout master --quiet)`
|
48
|
+
@repoBranches.get_current_branch.should eq 'master'
|
44
49
|
end
|
45
50
|
|
46
51
|
after(:each) do
|
@@ -52,13 +57,13 @@ module Gitit
|
|
52
57
|
|
53
58
|
# -------------------------------------------------------------------------
|
54
59
|
# -------------------------------------------------------------------------
|
55
|
-
describe
|
60
|
+
describe '#testBranchCreationLocally' do
|
56
61
|
|
57
62
|
before(:each) do
|
58
63
|
FileUtils.mkpath TEST_REPO_PATH
|
59
64
|
git = Git.new(TEST_REPO_PATH)
|
60
|
-
@
|
61
|
-
@
|
65
|
+
@my_repo = git.repo
|
66
|
+
@my_repo.init
|
62
67
|
@repoBranches = git.branches
|
63
68
|
|
64
69
|
File.open("#{TEST_REPO_PATH}/out.txt", "w+") { |file| file.write("boo!") }
|
@@ -70,36 +75,36 @@ module Gitit
|
|
70
75
|
|
71
76
|
end
|
72
77
|
|
73
|
-
it
|
74
|
-
@repoBranches.
|
75
|
-
@repoBranches.
|
78
|
+
it 'will fail to create a local branch' do
|
79
|
+
@repoBranches.create_local_branch('mybranch').should eq true
|
80
|
+
@repoBranches.create_local_branch('mybranch').should eq false
|
76
81
|
end
|
77
82
|
|
78
|
-
it
|
79
|
-
@repoBranches.
|
80
|
-
@repoBranches.
|
81
|
-
@repoBranches.
|
83
|
+
it 'will create a local branch successfully' do
|
84
|
+
@repoBranches.create_local_branch('mybranch').should eq true
|
85
|
+
@repoBranches.exists_locally?('mybranch').should eq true
|
86
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq false
|
82
87
|
end
|
83
88
|
|
84
|
-
it
|
85
|
-
@repoBranches.
|
86
|
-
@repoBranches.
|
87
|
-
@repoBranches.
|
88
|
-
@repoBranches.
|
89
|
+
it 'will fail to push a local branch to an invalid remote' do
|
90
|
+
@repoBranches.create_local_branch('mybranch').should eq true
|
91
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq false
|
92
|
+
@repoBranches.push_local_branch_to_remote('mybranch', 'badorigin', false).should eq false
|
93
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq false
|
89
94
|
end
|
90
95
|
|
91
|
-
it
|
92
|
-
@repoBranches.
|
93
|
-
@repoBranches.
|
94
|
-
@repoBranches.
|
95
|
-
@repoBranches.
|
96
|
+
it 'will push a local branch to the remote not forcing it' do
|
97
|
+
@repoBranches.create_local_branch('mybranch').should eq true
|
98
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq false
|
99
|
+
@repoBranches.push_local_branch_to_remote('mybranch', 'origin', false).should eq true
|
100
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq true
|
96
101
|
end
|
97
102
|
|
98
|
-
it
|
99
|
-
@repoBranches.
|
100
|
-
@repoBranches.
|
101
|
-
@repoBranches.
|
102
|
-
@repoBranches.
|
103
|
+
it 'will push a local branch to the remote forcing it' do
|
104
|
+
@repoBranches.create_local_branch('mybranch').should eq true
|
105
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq false
|
106
|
+
@repoBranches.push_local_branch_to_remote('mybranch', 'origin', true).should eq true
|
107
|
+
@repoBranches.exists_remotely?('mybranch', 'origin').should eq true
|
103
108
|
end
|
104
109
|
|
105
110
|
after(:each) do
|
data/spec/gitit_config_spec.rb
CHANGED
@@ -1,50 +1,73 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
-
#require "gitit"
|
3
2
|
|
4
3
|
module Gitit
|
5
4
|
|
6
5
|
describe Config do
|
7
6
|
|
8
|
-
#
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
before(:each) do
|
16
|
-
FileUtils.mkpath TEST_REPO_PATH
|
17
|
-
@git = Git.new(TEST_REPO_PATH)
|
18
|
-
@git.repo.init
|
19
|
-
@config = @git.config
|
20
|
-
end
|
21
|
-
|
22
|
-
it "will set the specified local value successfully" do
|
23
|
-
lambda{@config.setValue(KEY_NAME, KEY_VALUE)}.should_not raise_error
|
24
|
-
end
|
25
|
-
|
26
|
-
it "will retrieve the specified local value successfully" do
|
27
|
-
value = ""
|
28
|
-
lambda{@config.setValue(KEY_NAME, KEY_VALUE)}.should_not raise_error
|
29
|
-
lambda{value = @config.getValue(KEY_NAME)}.should_not raise_error
|
30
|
-
value.should eq KEY_VALUE
|
31
|
-
end
|
32
|
-
|
33
|
-
it "will set the specified global value successfully" do
|
34
|
-
lambda{@config.setGlobalValue(KEY_NAME, KEY_VALUE)}.should_not raise_error
|
35
|
-
end
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# -----------------------------------------------------------------------------
|
9
|
+
['--local', '--global', '--file /tmp/foo'].each { |mode|
|
10
|
+
|
11
|
+
# ---------------------------------------------------------------------------
|
12
|
+
# ---------------------------------------------------------------------------
|
13
|
+
%w(mytestkey mytestkey.withsub).each {|key_section|
|
36
14
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
15
|
+
# -------------------------------------------------------------------------
|
16
|
+
# -------------------------------------------------------------------------
|
17
|
+
describe "#TestConfig #{mode} with key_section #{key_section}" do
|
18
|
+
|
19
|
+
before(:each) do
|
20
|
+
FileUtils.mkpath TEST_REPO_PATH
|
21
|
+
@git = Git.new(TEST_REPO_PATH)
|
22
|
+
@git.repo.init
|
23
|
+
@config = Config.new(@git.repo, mode)
|
24
|
+
|
25
|
+
@key_name = 'bla'
|
26
|
+
@key = key_section + '.' + @key_name
|
27
|
+
@key_value = 'osd aas as dsaadk'.force_encoding('UTF-8')
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'will set the specified key to the specified value successfully' do
|
32
|
+
lambda{@config.set_value(@key, @key_value)}.should_not raise_error
|
33
|
+
|
34
|
+
`(git config #{mode} --unset #{@key})`
|
35
|
+
`(cd #{TEST_REPO_PATH} && git config #{mode} --remove-section #{key_section})`
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'will retrieve the specified value successfully' do
|
39
|
+
value = ''
|
40
|
+
lambda{@config.set_value(@key, @key_value)}.should_not raise_error
|
41
|
+
lambda{value = @config.get_value(@key)}.should_not raise_error
|
42
|
+
value.should eq @key_value
|
43
|
+
|
44
|
+
`(git config #{mode} --unset #{@key})`
|
45
|
+
`(cd #{TEST_REPO_PATH} && git config #{mode} --remove-section #{key_section})`
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'will unset the specified key successfully' do
|
49
|
+
lambda{@config.set_value(@key, @key_value)}.should_not raise_error
|
50
|
+
lambda{@config.unset_value(@key)}.should_not raise_error
|
51
|
+
lambda{@config.get_value(@key)}.should raise_error
|
52
|
+
|
53
|
+
`(cd #{TEST_REPO_PATH} && git config #{mode} --remove-section #{key_section})`
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'will remove the specified section successfully' do
|
57
|
+
lambda{@config.set_value(@key, @key_value)}.should_not raise_error
|
58
|
+
lambda{@config.unset_value(@key)}.should_not raise_error
|
59
|
+
lambda{@config.remove_section(key_section)}.should_not raise_error
|
60
|
+
lambda{@config.get_value(@key)}.should raise_error
|
61
|
+
end
|
62
|
+
|
63
|
+
after(:each) do
|
64
|
+
FileUtils.rm_rf TEST_REPO_PATH
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
49
72
|
end
|
50
73
|
end
|
data/spec/gitit_spec.rb
CHANGED
@@ -6,30 +6,30 @@ module Gitit
|
|
6
6
|
|
7
7
|
# -------------------------------------------------------------------------
|
8
8
|
# -------------------------------------------------------------------------
|
9
|
-
describe
|
9
|
+
describe '#initialize' do
|
10
10
|
|
11
|
-
TMP_PATH =
|
12
|
-
BAD_PATH =
|
13
|
-
TEST_REPO_PATH =
|
14
|
-
TEST_REPO_PATH_BARE =
|
11
|
+
TMP_PATH = '/tmp/'
|
12
|
+
BAD_PATH = '/adsdsadasdsa'
|
13
|
+
TEST_REPO_PATH = '/tmp/test_git'
|
14
|
+
TEST_REPO_PATH_BARE = '/tmp/test_git_bare'
|
15
15
|
|
16
16
|
before(:each) do
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
19
|
+
it 'will open fine given a valid repo' do
|
20
20
|
lambda{Git.new(Dir.pwd)}.should_not raise_error
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'will throw an error given an invalid repo' do
|
24
24
|
lambda{Git.new(BAD_PATH)}.should raise_error
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'will return true on valid repo' do
|
28
28
|
myRepo = Git.new(Dir.pwd).repo
|
29
29
|
myRepo.valid?.should eq true
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'will return false on invalid repo' do
|
33
33
|
myRepo = Git.new(TMP_PATH).repo
|
34
34
|
myRepo.valid?.should eq false
|
35
35
|
end
|
@@ -38,24 +38,24 @@ module Gitit
|
|
38
38
|
|
39
39
|
# -------------------------------------------------------------------------
|
40
40
|
# -------------------------------------------------------------------------
|
41
|
-
describe
|
41
|
+
describe '#initNewRepo' do
|
42
42
|
|
43
43
|
before(:each) do
|
44
44
|
FileUtils.mkpath TEST_REPO_PATH
|
45
45
|
git = Git.new(TEST_REPO_PATH)
|
46
|
-
@
|
46
|
+
@my_repo = git.repo
|
47
47
|
end
|
48
48
|
|
49
|
-
it
|
50
|
-
@
|
51
|
-
lambda{@
|
49
|
+
it 'will initialize a new repo on an existing folder' do
|
50
|
+
@my_repo.valid?.should eq false
|
51
|
+
lambda{@my_repo.init}.should_not raise_error
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
@
|
56
|
-
lambda{@
|
57
|
-
@
|
58
|
-
lambda{@
|
54
|
+
it 'will fail to initialize a new repo on an existing folder already initialized' do
|
55
|
+
@my_repo.valid?.should eq false
|
56
|
+
lambda{@my_repo.init}.should_not raise_error
|
57
|
+
@my_repo.valid?.should eq true
|
58
|
+
lambda{@my_repo.init}.should raise_error
|
59
59
|
end
|
60
60
|
|
61
61
|
after(:each) do
|
data/spec/gitit_status_spec.rb
CHANGED
@@ -7,75 +7,75 @@ module Gitit
|
|
7
7
|
|
8
8
|
# -------------------------------------------------------------------------
|
9
9
|
# -------------------------------------------------------------------------
|
10
|
-
describe
|
10
|
+
describe '#testRepoStatus' do
|
11
11
|
|
12
12
|
before(:each) do
|
13
13
|
FileUtils.mkpath TEST_REPO_PATH
|
14
14
|
git = Git.new(TEST_REPO_PATH)
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@
|
15
|
+
@my_repo = git.repo
|
16
|
+
@my_repo.init
|
17
|
+
@repo_status = git.status
|
18
18
|
|
19
19
|
`(cd #{TEST_REPO_PATH} && git config user.email "you@example.com")`
|
20
20
|
`(cd #{TEST_REPO_PATH} && git config user.name "example")`
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
25
|
-
@
|
24
|
+
it 'will tell us that the current branch is clean when nothing has been changed' do
|
25
|
+
@repo_status.clean?.should eq true
|
26
26
|
end
|
27
27
|
|
28
|
-
it
|
29
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
30
|
-
@
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
28
|
+
it 'will tell us that the current branch is not clean when there are untracked file' do
|
29
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w+') { |file| file.write('boo!') }
|
30
|
+
@repo_status.untracked_files?.should eq true
|
31
|
+
@repo_status.unstaged_files?.should eq false
|
32
|
+
@repo_status.uncommited_files?.should eq false
|
33
|
+
@repo_status.clean?.should eq false
|
34
34
|
end
|
35
35
|
|
36
|
-
it
|
37
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
36
|
+
it 'will tell us that the current branch is not clean when there are unstaged file' do
|
37
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w+') { |file| file.write('boo!') }
|
38
38
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
39
39
|
`(cd #{TEST_REPO_PATH} && git commit -am "wip")`
|
40
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
40
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w') { |file| file.write('bdssdsoo!') }
|
41
|
+
@repo_status.untracked_files?.should eq false
|
42
|
+
@repo_status.unstaged_files?.should eq true
|
43
|
+
@repo_status.uncommited_files?.should eq false
|
44
|
+
@repo_status.clean?.should eq false
|
45
45
|
end
|
46
46
|
|
47
|
-
it
|
48
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
47
|
+
it 'will tell us that the current branch is not clean when there are uncommited file' do
|
48
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w+') { |file| file.write('boo!') }
|
49
49
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
50
50
|
`(cd #{TEST_REPO_PATH} && git commit -am "wip")`
|
51
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
51
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w') { |file| file.write('bdssdsoo!') }
|
52
52
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
53
|
-
@
|
54
|
-
@
|
55
|
-
@
|
56
|
-
@
|
53
|
+
@repo_status.untracked_files?.should eq false
|
54
|
+
@repo_status.unstaged_files?.should eq false
|
55
|
+
@repo_status.uncommited_files?.should eq true
|
56
|
+
@repo_status.clean?.should eq false
|
57
57
|
end
|
58
58
|
|
59
|
-
it
|
60
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
61
|
-
@
|
59
|
+
it 'will tell us that there are untracked files after adding a new file' do
|
60
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w+') { |file| file.write('boo!') }
|
61
|
+
@repo_status.untracked_files?.should eq true
|
62
62
|
end
|
63
63
|
|
64
|
-
it
|
65
|
-
File.open("#{TEST_REPO_PATH}/out.txt", "w+") { |file| file.write(
|
64
|
+
it 'will tell us that there are unstage files after modifying a file' do
|
65
|
+
File.open("#{TEST_REPO_PATH}/out.txt", "w+") { |file| file.write('boo!') }
|
66
66
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
67
67
|
`(cd #{TEST_REPO_PATH} && git commit -am "wip")`
|
68
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
69
|
-
@
|
68
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w') { |file| file.write('bdssdsoo!') }
|
69
|
+
@repo_status.unstaged_files?.should eq true
|
70
70
|
end
|
71
71
|
|
72
|
-
it
|
73
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
72
|
+
it 'will tell us if there are uncommit files after adding a modified file to staging' do
|
73
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w+') { |file| file.write('boo!') }
|
74
74
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
75
75
|
`(cd #{TEST_REPO_PATH} && git commit -am "wip")`
|
76
|
-
File.open("#{TEST_REPO_PATH}/out.txt",
|
76
|
+
File.open("#{TEST_REPO_PATH}/out.txt", 'w') { |file| file.write('bdssdsoo!') }
|
77
77
|
`(cd #{TEST_REPO_PATH} && git add #{TEST_REPO_PATH}/out.txt)`
|
78
|
-
@
|
78
|
+
@repo_status.uncommited_files?.should eq true
|
79
79
|
end
|
80
80
|
|
81
81
|
after(:each) do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
if ENV[
|
1
|
+
if ENV['COVERAGE'] == 'yes'
|
2
2
|
require 'simplecov'
|
3
3
|
SimpleCov.start
|
4
4
|
end
|
@@ -13,5 +13,18 @@ require 'gitit'
|
|
13
13
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
14
14
|
|
15
15
|
RSpec.configure do |config|
|
16
|
-
|
16
|
+
original_stderr = $stderr
|
17
|
+
original_stdout = $stdout
|
18
|
+
config.before(:all) do
|
19
|
+
# Redirect stderr and stdout
|
20
|
+
$stderr = File.new(File.join(File.dirname(__FILE__), 'null.txt'), 'w')
|
21
|
+
$stdout = File.new(File.join(File.dirname(__FILE__), 'null.txt'), 'w')
|
22
|
+
`git config --global user.email "you@example.com"`
|
23
|
+
`git config --global user.name "Your Name"`
|
24
|
+
end
|
25
|
+
config.after(:all) do
|
26
|
+
$stderr = original_stderr
|
27
|
+
$stdout = original_stdout
|
28
|
+
end
|
17
29
|
end
|
30
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pat Laplante
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -131,6 +131,7 @@ extra_rdoc_files: []
|
|
131
131
|
files:
|
132
132
|
- .document
|
133
133
|
- .gitignore
|
134
|
+
- .idea/dictionaries/pat.xml
|
134
135
|
- .rspec
|
135
136
|
- .travis.yml
|
136
137
|
- Gemfile
|