mercurial-ruby 0.7.11 → 0.7.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.11
1
+ 0.7.12
@@ -6,7 +6,7 @@ require 'time'
6
6
  #
7
7
  module Mercurial
8
8
 
9
- VERSION = '0.7.11'
9
+ VERSION = '0.7.12'
10
10
 
11
11
  class Error < RuntimeError; end
12
12
 
@@ -27,8 +27,8 @@ module Mercurial
27
27
 
28
28
  def initialize(repository, name, options={})
29
29
  @repository = repository
30
- @name = name
31
- @status = options[:status] == 'closed' ? 'closed' : 'active'
30
+ @name = name.strip
31
+ @status = ['closed', 'inactive'].include?(options[:status]) ? options[:status] : 'active'
32
32
  @hash_id = options[:commit]
33
33
  end
34
34
 
@@ -39,6 +39,10 @@ module Mercurial
39
39
  def active?
40
40
  status == 'active'
41
41
  end
42
+
43
+ def inactive?
44
+ status == 'inactive'
45
+ end
42
46
 
43
47
  def closed?
44
48
  status == 'closed'
@@ -45,7 +45,18 @@ module Mercurial
45
45
  b.active?
46
46
  end
47
47
  end
48
-
48
+
49
+ # Return an array of {Mercurial::Branch Branch} instances for all inactive branches in the repository.
50
+ #
51
+ # === Example:
52
+ # repository.branches.inactive
53
+ #
54
+ def inactive(cmd_options={})
55
+ all(cmd_options).find_all do |b|
56
+ b.inactive?
57
+ end
58
+ end
59
+
49
60
  # Return an array of {Mercurial::Branch Branch} instances for all closed branches in the repository.
50
61
  #
51
62
  # === Example:
@@ -83,7 +94,7 @@ module Mercurial
83
94
  private
84
95
 
85
96
  def build(data)
86
- name, last_commit, status = *data.scan(/([\w-]+)\s+\d+:(\w+)\s*\(*(\w*)\)*/).first
97
+ name, last_commit, status = *data.scan(/([\w\- ]+)\s+\d+:(\w+)\s*\(*(\w*)\)*/).first
87
98
  Mercurial::Branch.new(
88
99
  repository,
89
100
  name,
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mercurial-ruby}
8
- s.version = "0.7.11"
8
+ s.version = "0.7.12"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ilya Sabanin"]
12
- s.date = %q{2013-08-08}
12
+ s.date = %q{2013-11-21}
13
13
  s.description = %q{Ruby API for Mercurial DVCS.}
14
14
  s.email = %q{ilya.sabanin@gmail.com}
15
15
  s.extra_rdoc_files = [
Binary file
@@ -1,58 +1,69 @@
1
1
  require File.dirname(__FILE__) + '/helper'
2
2
 
3
3
  describe Mercurial::BranchFactory do
4
-
4
+
5
5
  before do
6
6
  @repository = Mercurial::Repository.open(Fixtures.test_repo)
7
7
  end
8
-
8
+
9
9
  it "should find all branches" do
10
10
  branches = @repository.branches.all
11
- branches.size.must_equal 5
12
- branches.map(&:name).sort.must_equal %w(branch-from-remote another-branch new-branch old-branch default).sort
13
- branches.map(&:status).sort.must_equal %w(active active closed active active).sort
11
+ branches.size.must_equal 6
12
+ branches.map(&:name).sort.must_equal ['another-branch', 'branch-from-remote', 'default', 'my branch', 'new-branch', 'old-branch']
13
+ branches.map(&:status).sort.must_equal %w(active active active active closed inactive)
14
14
  end
15
15
 
16
16
  it "should iterate through branches" do
17
17
  names = []
18
18
  @repository.branches.each{|b| names << b.name }
19
- names.size.must_equal 5
20
- names.must_equal %w(default another-branch branch-from-remote new-branch old-branch)
19
+ names.size.must_equal 6
20
+ names.must_equal ['default', 'my branch', 'another-branch', 'branch-from-remote', 'new-branch', 'old-branch']
21
21
  end
22
-
22
+
23
23
  it "should find active branches" do
24
24
  branches = @repository.branches.active
25
25
  branches.size.must_equal 4
26
- branches.map(&:name).sort.must_equal %w(another-branch new-branch default branch-from-remote).sort
26
+ branches.map(&:name).sort.must_equal ['another-branch', 'default', 'branch-from-remote', 'my branch'].sort
27
27
  branches.map(&:status).must_equal %w(active active active active)
28
28
  end
29
-
29
+
30
+ it "should find inactive branches" do
31
+ branches = @repository.branches.inactive
32
+ branches.size.must_equal 1
33
+ branches.map(&:name).must_equal %w(new-branch)
34
+ branches.map(&:status).must_equal %w(inactive)
35
+ end
36
+
30
37
  it "should find closed branches" do
31
38
  branches = @repository.branches.closed
32
39
  branches.size.must_equal 1
33
40
  branches.map(&:name).must_equal %w(old-branch)
34
41
  branches.map(&:status).must_equal %w(closed)
35
42
  end
36
-
43
+
37
44
  it "should find branch by name" do
38
- branch = @repository.branches.by_name('new-branch')
45
+ branch = @repository.branches.by_name('default')
39
46
  branch.must_be_kind_of(Mercurial::Branch)
40
47
  branch.status.must_equal 'active'
48
+
49
+ branch = @repository.branches.by_name('new-branch')
50
+ branch.must_be_kind_of(Mercurial::Branch)
51
+ branch.status.must_equal 'inactive'
41
52
  end
42
-
53
+
43
54
  it "should not find a branch by inexistent name" do
44
55
  @repository.branches.by_name('bla-branch-f').must_equal nil
45
56
  end
46
-
57
+
47
58
  it "should return branches for commit" do
48
59
  branches = @repository.branches.for_commit('bf6386c0a0cc')
49
- branches.size.must_equal 5
50
- branches.map(&:name).sort.must_equal %w(old-branch new-branch branch-from-remote another-branch default).sort
60
+ branches.size.must_equal 6
61
+ branches.map(&:name).sort.must_equal ['old-branch', 'new-branch', 'branch-from-remote', 'another-branch', 'default', 'my branch'].sort
51
62
  end
52
63
 
53
64
  it "should find branch's full hash_id" do
54
65
  branch = @repository.branches.all.first
55
- branch.hash_id.must_equal '2b03a87dbf4cb1a95b2417d8e2eac801c450b624'
66
+ branch.hash_id.must_equal '7ac2dcb09643805a97549210e5d0e5511d091c31'
56
67
  end
57
-
68
+
58
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercurial-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 11
10
- version: 0.7.11
9
+ - 12
10
+ version: 0.7.12
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ilya Sabanin
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-08-08 00:00:00 -04:00
18
+ date: 2013-11-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency