gitit 0.7.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d6eccd073e28fa27af29c78a39eea588380603d
4
- data.tar.gz: bdb4ea6a45379dd2bfd0f8e59fd6b01efa869284
3
+ metadata.gz: 23fb8d00f8124e0bf2b40c92e825473c3382f0bb
4
+ data.tar.gz: 77d0f01adadb44f35b3d6754135d21a586afc492
5
5
  SHA512:
6
- metadata.gz: e6145b556fde747538ae62b5491884790e22706a11149fb8812bb3bbcda4ad6f72d4c7fb1a2d743c351cba67c4188bb36026c5042ab7540d4bda2b4341deab7f
7
- data.tar.gz: 8ffc989495d607f3c6e0f2fb0ed7bde73181822d50486c658d2d24ea322e9c108a9f9f999b471c9ce50f580f95055f78ace9f2358264970f3bf2a9066b4ca5e3
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.7.0
1
+ 1.0.0
@@ -1,4 +1,4 @@
1
- require "gitit/command_executor"
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
- executeCommand("diff --cached --no-ext-diff --ignore-submodules --quiet --exit-code")
23
- return true if $?.exitstatus == 1
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 "gitit/command_executor"
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 existsLocally?(name)
19
- executeCommand("branch --no-color | sed 's/^[* ] //' | grep #{name}")
20
- return true if $?.exitstatus == 0
21
- return false
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 existsRemotely?(name, remote)
27
- executeCommand("branch -r --no-color | sed 's/^[* ] //' | grep #{remote}/#{name}")
28
- return true if $?.exitstatus == 0
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 createLocalBranch(name)
35
- executeCommand("branch --quiet #{name}")
36
- return true if $?.exitstatus == 0
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 pushLocalBranchToRemote(name, remote, force)
43
- executeCommand("push --quiet -f #{remote} #{name}") if force
44
- executeCommand("push --quiet #{remote} #{name}") unless force
45
- return true if $?.exitstatus == 0
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 updateFromRemote(branchName, remote)
55
+ #def update_from_remote(branch_name, remote)
52
56
 
53
- end
57
+ #end
54
58
 
55
59
  end
56
60
 
@@ -1,4 +1,4 @@
1
- require "gitit/command_executor"
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 getValue(key)
19
- value = executeCommand("config --null --get #{key}")
20
- raise "failure running command" if $?.exitstatus != 0
21
- value = value.slice!(0, value.length-1)
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 setValue(key, value)
27
+ def set_value(key, value)
28
28
  val = value
29
- executeCommand("config \"#{key}\" \"#{val}\"")
30
- raise "failure running command" if $?.exitstatus != 0
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 getGlobalValue(key)
36
- value = executeCommand("config --global --null --get #{key}")
37
- raise "failure running command" if $?.exitstatus != 0
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 setGlobalValue(key, value)
45
- val = value
46
- executeCommand("config --global \"#{key}\" \"#{val}\"")
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 executeCommand(command)
9
- gitCommand = ["git", command].join(" ")
10
- result = `(cd #{@repo.location} && #{gitCommand})`
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
@@ -1,4 +1,4 @@
1
- require "gitit/command_executor"
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
- return !unstagedFiles? && !uncommitedFiles? && !untrackedFiles?
19
+ !unstaged_files? && !uncommited_files? && !untracked_files?
20
20
  end
21
21
 
22
22
  # -------------------------------------------------------------------------
23
23
  # -------------------------------------------------------------------------
24
- def unstagedFiles?
25
- executeCommand("diff-files --name-status --diff-filter=M --exit-code")
26
- return true if $?.exitstatus == 1
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 uncommitedFiles?
33
- executeCommand("diff --cached --no-ext-diff --ignore-submodules --quiet --exit-code")
34
- return true if $?.exitstatus == 1
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 untrackedFiles?
41
- gitRes = executeCommand("status --porcelain | grep ??")
42
- return true if $?.exitstatus == 0
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 "gitit"
2
- require "gitit/repo"
1
+ require 'gitit'
2
+ require 'gitit/repo'
3
3
 
4
- Dir[File.dirname(__FILE__) + "/command_*.rb"].each do |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 "gitit"
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 "Invalid path specified" unless File.directory? location
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
- commandres = `(cd #{@location} && git rev-parse --git-dir >/dev/null 2>&1)`
21
- return true unless $?.exitstatus != 0
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 "already a git repo" if valid?
29
- commandres = `(cd #{@location} && git init)`
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
@@ -1,3 +1,3 @@
1
1
  module Gitit
2
- VERSION = "0.1.1"
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/gitit.rb CHANGED
@@ -1,5 +1,5 @@
1
- require "gitit/version"
2
- require "gitit/git"
1
+ require 'gitit/version'
2
+ require 'gitit/git'
3
3
 
4
4
  module Gitit
5
5
  end
@@ -6,17 +6,17 @@ module Gitit
6
6
 
7
7
  # -------------------------------------------------------------------------
8
8
  # -------------------------------------------------------------------------
9
- describe "#testRepoBranch" do
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
- @myRepo = git.repo
15
- @myRepo.init
16
- @repoBranch = Gitit::Branch.new(@myRepo, "master")
14
+ @my_repo = git.repo
15
+ @my_repo.init
16
+ @repoBranch = Gitit::Branch.new(@my_repo, 'master')
17
17
  end
18
18
 
19
- it "will tell us if the branch is a valid branch" do
19
+ it 'will tell us if the branch is a valid branch' do
20
20
  end
21
21
 
22
22
  after(:each) do
@@ -6,13 +6,13 @@ module Gitit
6
6
 
7
7
  # -------------------------------------------------------------------------
8
8
  # -------------------------------------------------------------------------
9
- describe "#testBranchesExistance" do
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
- @myRepo = git.repo
15
- @myRepo.init
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 "will successfully find a valid local branch" do
31
- @repoBranches.existsLocally?("master").should eq true
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 "will fail to find an invalid local branch" do
35
- @repoBranches.existsLocally?("asdasdsad").should eq false
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 "will successfully find a valid remote branch" do
39
- @repoBranches.existsRemotely?("master", "origin").should eq true
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 "will fail to find an invalid remote branch" do
43
- @repoBranches.existsRemotely?("asdasdsad", "origin").should eq false
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 "#testBranchCreationLocally" do
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
- @myRepo = git.repo
61
- @myRepo.init
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 "will fail to create a local branch" do
74
- @repoBranches.createLocalBranch("mybranch").should eq true
75
- @repoBranches.createLocalBranch("mybranch").should eq false
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 "will create a local branch successfully" do
79
- @repoBranches.createLocalBranch("mybranch").should eq true
80
- @repoBranches.existsLocally?("mybranch").should eq true
81
- @repoBranches.existsRemotely?("mybranch", "origin").should eq false
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 "will fail to push a local branch to an invalid remote" do
85
- @repoBranches.createLocalBranch("mybranch").should eq true
86
- @repoBranches.existsRemotely?("mybranch", "origin").should eq false
87
- @repoBranches.pushLocalBranchToRemote("mybranch", "badorigin", false).should eq false
88
- @repoBranches.existsRemotely?("mybranch", "origin").should eq false
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 "will push a local branch to the remote not forcing it" do
92
- @repoBranches.createLocalBranch("mybranch").should eq true
93
- @repoBranches.existsRemotely?("mybranch", "origin").should eq false
94
- @repoBranches.pushLocalBranchToRemote("mybranch", "origin", false).should eq true
95
- @repoBranches.existsRemotely?("mybranch", "origin").should eq true
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 "will push a local branch to the remote forcing it" do
99
- @repoBranches.createLocalBranch("mybranch").should eq true
100
- @repoBranches.existsRemotely?("mybranch", "origin").should eq false
101
- @repoBranches.pushLocalBranchToRemote("mybranch", "origin", true).should eq true
102
- @repoBranches.existsRemotely?("mybranch", "origin").should eq true
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
@@ -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
- describe "#Config" do
11
-
12
- KEY_NAME = "mytest.bla"
13
- KEY_VALUE = "osd aas as dsaadk".force_encoding("UTF-8")
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
- it "will retrieve the specified global value successfully" do
38
- value = ""
39
- lambda{@config.setGlobalValue(KEY_NAME, KEY_VALUE)}.should_not raise_error
40
- lambda{value = @config.getGlobalValue(KEY_NAME)}.should_not raise_error
41
- value.should eq KEY_VALUE
42
- end
43
-
44
- after(:each) do
45
- FileUtils.rm_rf TEST_REPO_PATH
46
- end
47
-
48
- end
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 "#initialize" do
9
+ describe '#initialize' do
10
10
 
11
- TMP_PATH = "/tmp/"
12
- BAD_PATH = "/adsdsadasdsa"
13
- TEST_REPO_PATH = "/tmp/test_git"
14
- TEST_REPO_PATH_BARE = "/tmp/test_git_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 "will open fine given a valid repo" do
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 "will throw an error given an invalid repo" do
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 "will return true on valid repo" do
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 "will return false on invalid repo" do
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 "#initNewRepo" do
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
- @myRepo = git.repo
46
+ @my_repo = git.repo
47
47
  end
48
48
 
49
- it "will initialize a new repo on an existing folder" do
50
- @myRepo.valid?.should eq false
51
- lambda{@myRepo.init}.should_not raise_error
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 "will fail to initialize a new repo on an existing folder already initialized" do
55
- @myRepo.valid?.should eq false
56
- lambda{@myRepo.init}.should_not raise_error
57
- @myRepo.valid?.should eq true
58
- lambda{@myRepo.init}.should raise_error
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
@@ -7,75 +7,75 @@ module Gitit
7
7
 
8
8
  # -------------------------------------------------------------------------
9
9
  # -------------------------------------------------------------------------
10
- describe "#testRepoStatus" do
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
- @myRepo = git.repo
16
- @myRepo.init
17
- @repoStatus = git.status
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 "will tell us that the current branch is clean when nothing has been changed" do
25
- @repoStatus.clean?.should eq true
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 "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
- @repoStatus.untrackedFiles?.should eq true
31
- @repoStatus.unstagedFiles?.should eq false
32
- @repoStatus.uncommitedFiles?.should eq false
33
- @repoStatus.clean?.should eq false
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 "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!") }
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", "w") { |file| file.write("bdssdsoo!") }
41
- @repoStatus.untrackedFiles?.should eq false
42
- @repoStatus.unstagedFiles?.should eq true
43
- @repoStatus.uncommitedFiles?.should eq false
44
- @repoStatus.clean?.should eq false
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 "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!") }
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", "w") { |file| file.write("bdssdsoo!") }
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
- @repoStatus.untrackedFiles?.should eq false
54
- @repoStatus.unstagedFiles?.should eq false
55
- @repoStatus.uncommitedFiles?.should eq true
56
- @repoStatus.clean?.should eq false
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 "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
- @repoStatus.untrackedFiles?.should eq true
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 "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!") }
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", "w") { |file| file.write("bdssdsoo!") }
69
- @repoStatus.unstagedFiles?.should eq true
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 "will tell us if there are uncommit files after adding a modifiled file to staging" do
73
- File.open("#{TEST_REPO_PATH}/out.txt", "w+") { |file| file.write("boo!") }
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", "w") { |file| file.write("bdssdsoo!") }
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
- @repoStatus.uncommitedFiles?.should eq true
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["COVERAGE"] == 'yes'
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.7.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: 2013-12-11 00:00:00.000000000 Z
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