Module: TicGitNG::Command::Sync

Defined in:
lib/ticgit-ng/command/sync.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/ticgit-ng/command/sync.rb', line 16

def execute
  begin
    if options.repo and options.no_push
      tic.sync_tickets(options.repo, false)
    elsif options.repo
      tic.sync_tickets(options.repo)
    elsif options.no_push
      tic.sync_tickets('origin', false)
    else
      tic.sync_tickets()
    end
  rescue Git::GitExecuteError => e
    if e.message[/does not appear to be a git repository/]
      repo= e.message.split("\n")[0][/^[^:]+/][/"\w+"/].gsub('"','')
      puts "Could not sync because git returned the following error:\n#{e.message.split("\n")[0][/[^:]+$/].strip}"
      exit
    end
  end 
end

#parser(opts) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/ticgit-ng/command/sync.rb', line 4

def parser(opts)
  opts.banner = "Usage: ti sync [options]"
  opts.on_head(
    "-r REPO", "--repo REPO", "Sync ticgit-ng branch with REPO"){|v|
    options.repo = v
  }
  opts.on_head(
    "-n", "--no-push", "Do not push to the remote repo"){|v|
    options.no_push = true
  }
end