fossgit 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/fossgit +3 -15
  3. data/lib/fossgit.rb +44 -13
  4. metadata +2 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f89e1271f8492c9e3b00cb7dc853624f4a8d45f
4
- data.tar.gz: 5bfde8253a5a00e3b589734ff913ef87b7881020
3
+ metadata.gz: b587f5714e832075d9bfa3935c3814e242267712
4
+ data.tar.gz: 0e0dd8b1f92c433492dd35873f254494b727de1f
5
5
  SHA512:
6
- metadata.gz: 2403e9e4bc37f9dd76679dffdac327d114296038385af9da4c91f580ade69864497c2e61e5318d57cdda5973dacdca3a955300db5368083b39f822ed90e4fb7f
7
- data.tar.gz: 402e5d4d0379c38db310bcdad31e789b9f388c010965b3fb1f20538d564b17f023d276396543536c88a6c5be1899f06ae72a90e06c9f495ab9beaa457f6eb44f
6
+ metadata.gz: fd6d9a5534f350c48b55ed9c754e031e058ff7bdba4401417999f6cac2df4394e7f4bc09243c9eabd2b002b28d1e8e0cb690d323083dabe36740dac45f629e48
7
+ data.tar.gz: 9edbe6e60d9d38398e4c196cce02d191afe45e6ab8cbd665b297a1758fd7cec5837fc557ce753baefb6564253645871bd429db69c40579bdaabb864272748ff6
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fossgit'
3
3
 
4
- @fossil_repository = nil
4
+ @fg = FossGit.new Dir.pwd
5
5
 
6
6
  def mirror_command
7
7
  [fossil_command, sed_command, git_command].join '|'
@@ -16,7 +16,7 @@ def fossil_command
16
16
 
17
17
  cmd << "--import-marks #{fossil_marks}" if update_export?
18
18
  cmd << "--export-marks #{fossil_marks}"
19
- cmd << fossil_repository
19
+ cmd << @fg.fossil_repository
20
20
 
21
21
  cmd.join ' '
22
22
  end
@@ -64,22 +64,10 @@ def option_switch? long_name
64
64
  ARGV.delete "-#{long_name[0]}" or ARGV.delete "--#{long_name}"
65
65
  end
66
66
 
67
- def fossil_repository
68
- idregex = /^repository: +/
69
-
70
- @fossil_repository ||= File.absolute_path(
71
- `fossil status`.split(/\n/).select do |line|
72
- line.match idregex
73
- end.first.sub idregex, ''
74
- )
75
- end
76
-
77
67
  name = File.basename $0
78
68
 
79
- fg = FossGit.new
80
-
81
69
  if option_switch? 'help'
82
- puts fg.help_text name
70
+ puts FossGit.help_text name
83
71
  exit
84
72
  elsif option_switch? 'version'
85
73
  puts [name, FossGit.version].join ' '
@@ -1,9 +1,19 @@
1
1
  class FossGit
2
+ attr_reader :checkout_path
3
+ attr_reader :fossil_repository
4
+
5
+ def initialize checkout_path=''
6
+ @checkout_path = checkout_path
7
+ @checkout_path = get_element_matching :'local-root'
8
+
9
+ @fossil_repository = get_repository_path
10
+ end
11
+
2
12
  def self.version
3
- '1.0.1'
13
+ '1.0.2'
4
14
  end
5
15
 
6
- def help_text name='fossgit'
16
+ def self.help_text name='fossgit'
7
17
  help = <<-EOF
8
18
 
9
19
  FossGit provides a simple tool for creating Git mirrors of Fossil
@@ -19,8 +29,8 @@ class FossGit
19
29
 
20
30
  By default, when exporting to local Git repository GITREPO, #{name}
21
31
  attempts to push updates to a configured upstream Git repository. It
22
- harmlessly fails to push if no upstream repository is configured for the
23
- local Git repository.
32
+ harmlessly fails to push if no upstream repository is configured for
33
+ the local Git repository.
24
34
 
25
35
  OPTIONS/ARGUMENTS:
26
36
 
@@ -28,18 +38,18 @@ class FossGit
28
38
  arguments.
29
39
 
30
40
  -c CHECKOUT Specify the location of your Fossil repository's open
31
- checkout, CHECKOUT. This is optional; you may simply use
32
- this tool from within an open checkout of your Fossil
33
- repository instead.
41
+ checkout, CHECKOUT. This is optional; you may simply
42
+ use this tool from within an open checkout of your
43
+ Fossil repository instead.
34
44
 
35
- -l Perform local-only mirror operations, without trying to
36
- push Git updates to a remote repository. By default,
37
- #{name} tries to push to an upstream Git repository
38
- whenever it exports from Fossil to Git.
45
+ -l Perform local-only mirror operations, without trying
46
+ to push Git updates to a remote repository. By
47
+ default, #{name} tries to push to an upstream Git
48
+ repository whenever it exports from Fossil to Git.
39
49
 
40
50
  -t Dump export to STDOUT rather than sending it to Git.
41
- This overrides the `-l` option and GITREPO argument, if
42
- present.
51
+ This overrides the `-l` option and GITREPO argument,
52
+ if present.
43
53
 
44
54
  GITREPO Specify the location of your local Git repository.
45
55
 
@@ -53,4 +63,25 @@ class FossGit
53
63
 
54
64
  EOF
55
65
  end
66
+
67
+ private
68
+
69
+ def get_repository_path
70
+ File.absolute_path get_element_matching :repository
71
+ end
72
+
73
+ def get_element_matching key
74
+ key_regex = /^#{key}: +/
75
+ fossil_status.select {|line| line.match key_regex }.first.sub key_regex, ''
76
+ end
77
+
78
+ def fossil_status
79
+ Dir.chdir checkout_path
80
+
81
+ if system 'fossil status'
82
+ `fossil status`.split(/\n/)
83
+ else
84
+ raise ArgumentError, "#{checkout_path} is not a valid checkout path"
85
+ end
86
+ end
56
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fossgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Perrin
@@ -10,8 +10,7 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |2
14
- Maintain a presence in Git hosting for Fossil projects.
13
+ description: " Maintain a presence in Git hosting for Fossil projects.\n"
15
14
  email: code@apotheon.net
16
15
  executables:
17
16
  - fossgit