Class: BetweenMeals::Repo::Svn

Inherits:
BetweenMeals::Repo show all
Defined in:
lib/between_meals/repo/svn.rb,
lib/between_meals/repo/svn/cmd.rb

Defined Under Namespace

Classes: Cmd

Instance Attribute Summary

Attributes inherited from BetweenMeals::Repo

#bin, #repo_path

Instance Method Summary collapse

Methods inherited from BetweenMeals::Repo

#create, #email, get, #head, #head_msg, #head_msg=, #head_parents, #initialize, #last_author, #last_msg, #last_msg=, #name, #status

Constructor Details

This class inherits a constructor from BetweenMeals::Repo

Instance Method Details

#changes(start_ref, end_ref) ⇒ Object

Return files changed between two revisions



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/between_meals/repo/svn.rb', line 58

def changes(start_ref, end_ref)
  valid_ref?(start_ref)
  valid_ref?(end_ref) if end_ref

  @logger.info("Diff between #{start_ref} and #{end_ref}")
  changes = @cmd.diff(start_ref, end_ref, @repo_path).stdout

  begin
    parse_status(changes).compact
  rescue StandardError => e
    @logger.error(
      'Something went wrong. Please report this output.',
    )
    @logger.error(e)
    stdout.lines.each do |line|
      @logger.error(line.strip)
    end
    exit(1)
  end
end

#checkout(url) ⇒ Object



53
54
55
# File 'lib/between_meals/repo/svn.rb', line 53

def checkout(url)
  @cmd.co(url, @repo_path)
end

#exists?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/between_meals/repo/svn.rb', line 35

def exists?
  Dir.exists?(Pathname.new(@repo_path).join('.svn'))
end

#filesObject



85
86
87
88
89
# File 'lib/between_meals/repo/svn.rb', line 85

def files
  @cmd.ls.stdout.split("\n").map do |x|
    { :path => x, :status => :created }
  end
end

#head_revObject



39
40
41
42
43
44
# File 'lib/between_meals/repo/svn.rb', line 39

def head_rev
  @cmd.info(@repo_path).stdout.each_line do |line|
    m = line.match(/Last Changed Rev: (\d+)$/)
    return m[1] if m
  end
end

#latest_revisionObject



46
47
48
49
50
51
# File 'lib/between_meals/repo/svn.rb', line 46

def latest_revision
  @cmd.info(@repo_path).stdout.each_line do |line|
    m = line.match(/Revision: (\d+)$/)
    return m[1] if m
  end
end

#setupObject



26
27
28
29
30
31
32
33
# File 'lib/between_meals/repo/svn.rb', line 26

def setup
  @bin = 'svn'
  @cmd = BetweenMeals::Repo::Svn::Cmd.new(
    :bin => @bin,
    :cwd => '/tmp',
    :logger => @logger,
  )
end

#updateObject



79
80
81
82
83
# File 'lib/between_meals/repo/svn.rb', line 79

def update
  @cmd.cleanup(@repo_path)
  @cmd.revert(@repo_path)
  @cmd.update(@repo_path)
end

#upstream?Boolean

Returns:

  • (Boolean)


91
# File 'lib/between_meals/repo/svn.rb', line 91

def upstream?; end

#valid_ref?(ref) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
96
97
# File 'lib/between_meals/repo/svn.rb', line 93

def valid_ref?(ref)
  @cmd.info_r(ref, @repo_path)
rescue StandardError
  raise Changeset::ReferenceError
end