File: sync.rb

package info (click to toggle)
ticgit 1.0.2.18-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 488 kB
  • sloc: ruby: 2,848; sh: 124; makefile: 16
file content (37 lines) | stat: -rw-r--r-- 1,110 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
module TicGitNG
  module Command
    module Sync
      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

      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
    end
  end
end