fossgit 1.0.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (7) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE +5 -5
  3. data/README.md +89 -24
  4. data/bin/fossgit +60 -132
  5. data/lib/fossgit.rb +110 -1
  6. data/lib/fossgit/cli.rb +185 -0
  7. metadata +13 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ff8a4c882972941862c63ab14c1a6a7612523c3e
4
- data.tar.gz: f7057fc31c57762a4d3ff715a66a8c0a9ef23eb8
2
+ SHA256:
3
+ metadata.gz: 18818769a77db453ed44fcaa69acb89e666ff498596553d2bf7a118d2a91a350
4
+ data.tar.gz: 76d7ea584d44590bf4ba3bdce854fa40896e6f6414e2fde76f26743bed43b316
5
5
  SHA512:
6
- metadata.gz: 46fc13e318b8ae5bcf8303e2f6ea6e6868894c3537d5eeed767a8f98fda325af781a3ff8dfc4de111da9001f9542830772db02258abaec5e63e968d99da4bc77
7
- data.tar.gz: 065d66e51b3073b7cec46bc8bbf238a555a5af678634f1b45d568ad558e47d84502a5faa73a3a6e8a59fbea3bd34b51fbd6a4bd627cfea4fc2baeb8c0354be09
6
+ metadata.gz: a1e83aed39084be285a4ff0c045c6516a2721c2211f62ce26b5dae5ed68ded776fa374dfc30277f03d53eca97c0355a91f272a8227979c8da7c3137cef369f3c
7
+ data.tar.gz: 0c3ad51586b0fc37e9b31d29c007826c54eb6d90fca8da872a0c5c09cb9b493a38a63cced9a0f87e507fddda3e904a4d4158da4c96071ee58a9c183543f7a7dc
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- FossGit: Copyright 2016 Chad Perrin, released under the terms of version 0.4 of
1
+ FossGit: Copyright 2016 Chad Perrin, released under the terms of version 0.5 of
2
2
  the Copyfree Open Innovation License.
3
3
 
4
4
  ## Terms and Conditions
@@ -17,10 +17,10 @@ and/or otherwise deal in the licensed material without restriction.
17
17
  license to reproduce, modify, distribute, publish, sell, use, and/or otherwise
18
18
  deal in the licensed material without restriction, for any and all patents:
19
19
 
20
- a. Held presently or in the future by each such holder of copyright or
21
- other legal privilege, author or assembler, or contributor, necessarily
22
- infringed by the contributions alone or by combination with the work, of
23
- that privilege holder, author or assembler, or contributor.
20
+ a. Held by each such holder of copyright or other legal privilege, author
21
+ or assembler, or contributor, necessarily infringed by the contributions
22
+ alone or by combination with the work, of that privilege holder, author or
23
+ assembler, or contributor.
24
24
 
25
25
  b. Necessarily infringed by the work at the time that holder of copyright
26
26
  or other privilege, author or assembler, or contributor made any
data/README.md CHANGED
@@ -1,25 +1,97 @@
1
1
  # fossgit
2
2
 
3
- This is a simple command line utility for creating and updating Git
3
+ FossGit provides a simple command line utility for creating and updating Git
4
4
  repositories as (one-way) mirrors of Fossil repositories.
5
5
 
6
6
  ## Installation
7
7
 
8
- Clone it from the [Fossil repository](https://fossrec.com/u/apotheon/fossgit/)
9
- or the [GitHub mirror](https://github.com/apotheon/fossgit/).
8
+ Install the [Ruby Gem][gem]:
10
9
 
11
- Copy the `fossgit` file to a directory in your execution path, create a symlink
12
- or hardlink to the repository's `fossgit` file in a directory in your execution
13
- path, add its location in this repository to your execution path, or execute it
14
- by entering the explicit path to the `fossgit` file at a shell prompt.
10
+ $ gem install fossgit
11
+
12
+ If, for some reason, that is not an available option for you or you wish to do
13
+ things the hard way, there is another installation method:
14
+
15
+ 1. Clone it from the [Fossil repository][frepo], the [GitHub][ghrepo] mirror,
16
+ or the [GitLab][glrepo] mirror.
17
+
18
+ 2. Build a gem, using this command:
19
+
20
+ gem build fossgit.gemspec
21
+
22
+ 3. Install the gem, using this command, using the whole filename of the gem
23
+ filename, substituting the actual version number for `<version`:
24
+
25
+ gem install fossgit-<version>
26
+
27
+ If that still does not suit your needs, you're on your own for now. I'd be
28
+ happy to accept suggestions for additional installation methods to describe.
15
29
 
16
30
  ## Usage
17
31
 
32
+ After installation, you can use this command to see documentation for command
33
+ line usage and (optional) configuration:
34
+
35
+ $ fossgit -h
36
+
37
+ ### Basic Command Line
38
+
18
39
  With an open checkout of your Fossil repository:
19
40
 
20
41
  $ cd /path/to/open/fossil/checkout
21
42
  $ fossgit /path/to/git/repository
22
43
 
44
+ ### Config
45
+
46
+ The following is just a basic introduction to FossGit configuration. See full
47
+ config documentation via the command line tool's `-h` option.
48
+
49
+ By placing a config file in the directory that will serve as your working
50
+ directory while running `fossgit` (typically the root of your Fossil repository
51
+ checkout directory tree), you can do away with the need to specify the path to
52
+ the local Git repository mirror. Simply create a file there called `.fossgit`
53
+ containing the following:
54
+
55
+ gitrepo: /path/to/gitdir/reponame
56
+
57
+ You can then run the command without arguments:
58
+
59
+ $ cd /path/to/open/fossil/checkout
60
+ $ fossgit
61
+
62
+ You can also place a `.fossgit` config file in your home directory, in which
63
+ case you may wish to specify the path to a directory in which you keep all your
64
+ Git repository mirrors and let `fossgit` infer your repository name from the
65
+ project-name setting in your Fossil repository:
66
+
67
+ gitpath: /path/to/gitdir
68
+
69
+ Once again, this allows you to run the command without arguments, but in this
70
+ case you should ensure the "project name" setting has been configured in your
71
+ Fossil repository, because it will default to using that to find your local Git
72
+ mirror. If you want to specify a different Git repository name, using the
73
+ `gitrepo` setting in a `.fossgit` file within the checkout of your Fossil
74
+ repository as described above might be a better option.
75
+
76
+ You can check whether your project name has been configured by running this
77
+ command from within an open checkout:
78
+
79
+ $ fossil info
80
+
81
+ If the `project-name` line says `<unnamed>`, the project name is unconfigured.
82
+ You can cofigure it yourself; open the web UI for the repository (e.g. run
83
+ `fossil serve` from within an open checkout and open `localhost:8080` in your
84
+ browser), navigate to `Admin > Configuration`, fill in the Project Name field,
85
+ and click the button to apply your changes.
86
+
87
+ If you do both, the most-specific option (gitrepo) will be chosen as the target
88
+ Git repository, which is probably a good idea if, for a specific project, you
89
+ have not configured the Fossil repository's project-name setting, or if you
90
+ want to default to updating a mirror with a different name than the Fossil
91
+ project-name. Specifying a repository path at the command line will cause
92
+ `fossgit` to ignore both, and just use the command line argument as the target
93
+ Git repository path.
94
+
23
95
  ## Dependencies
24
96
 
25
97
  * Fossil SCM
@@ -33,25 +105,18 @@ With an open checkout of your Fossil repository:
33
105
  In order from most preferred to least preferred:
34
106
 
35
107
  * Add a ticket in the Fossil repository.
36
- * Add a ticket in the GitHub repository (then I'll copy it to Fossil).
108
+ * Add a ticket in the GitHub or GitLab repository (and I'll copy it to Fossil).
37
109
 
38
110
  ## Roadmap
39
111
 
40
- * Make this a stand-alone Ruby Gem some day, maybe.
41
- * Add tests, maybe.
42
- * Add automatic GitHub publishing, maybe.
112
+ * Add autovivifying functionality for a local Git mirror.
113
+ * Add autovivifying functionality for GitHub and GitLab remotes.
114
+ * Add more tests.
115
+ * Change defaults for v2.0, perhaps.
43
116
  * Incorporate this functionality into FossRec, a more comprehensive tool.
117
+ * Organize lib APIs and document them. (Don't rely on undocumented APIs.)
44
118
 
45
- ## Development
46
-
47
- The discerning programmer may look over FossGit in its current form and realize
48
- it is neither object-oriented nor functional in its design. It is, in fact, a
49
- pretty straightforward procedural program, written in Ruby (an odd language to
50
- use for procedural programming, perhaps). The reason for this is simple: it is
51
- in essence a glorified shell script. There are plans to make it part of a
52
- larger set of libraries and utilities (see the Roadmap), and it will need to
53
- undergo a fair bit of redesign as part of that; I expect it to be largely
54
- unrecognizable by then.
55
-
56
- Much of this work was done on Christmas weekend 2016. That may or may not be
57
- significant.
119
+ [gem]: https://rubygems.org/gems/fossgit
120
+ [frepo]: https://fossrec.com/u/apotheon/fossgit
121
+ [ghrepo]: https://github.com/apotheon/fossgit
122
+ [glrepo]: https://gitlab.com/apotheon/fossgit
data/bin/fossgit CHANGED
@@ -1,156 +1,84 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'fossgit'
3
+ require 'fossgit/cli'
3
4
 
4
- @fossil_repository = nil
5
+ @cli = CLI.new ARGV, File.basename($0)
6
+ @fg = FossGit.new (@cli.get_option('checkout') or Dir.pwd)
5
7
 
6
- def mirror_command
7
- [fossil_command, sed_command, git_command].join '|'
8
- end
9
-
10
- def sed_command
11
- %q{sed 's/^\(committer \+\)\([^ ]\+@[^ ]\+\)\( *<\)\(\w\+\)\(>.*\)$/\1\4\3\2\5/'}
12
- end
13
-
14
- def fossil_command
15
- cmd = ['fossil export --git']
16
-
17
- cmd << "--import-marks #{fossil_marks}" if update_export?
18
- cmd << "--export-marks #{fossil_marks}"
19
- cmd << fossil_repository
20
-
21
- cmd.join ' '
22
- end
23
-
24
- def git_command
25
- cmd = ['git fast-import']
26
-
27
- cmd << "--import-marks=#{git_marks}" if update_export?
28
- cmd << "--export-marks=#{git_marks}"
29
-
30
- cmd.join ' '
31
- end
32
-
33
- def push_command
34
- '; git checkout trunk; git push origin trunk'
35
- end
36
-
37
- def update_export?
38
- File.exist? git_marks and File.exist? fossil_marks
39
- end
40
-
41
- def fossil_marks
42
- fossil_file 'fossil.marks'
43
- end
44
-
45
- def git_marks
46
- fossil_file 'git.marks'
47
- end
8
+ Dir.chdir @fg.checkout_path
48
9
 
49
- def fossil_file filename
50
- File.join fossil_path, filename
10
+ if @cli.config['gitdir'] and @fg.project_name
11
+ @cli.config['gitrepo'] ||= File.join(@cli.config['gitdir'], @fg.project_name)
51
12
  end
52
13
 
53
- def fossil_path
54
- get_option '-c' or Dir.pwd
55
- end
14
+ @cli.parse_switches %w(all help local newgit text-export version)
56
15
 
57
- def get_option opt, default=nil
58
- ARGV.index(opt).tap do |val|
59
- return val ? (ARGV.delete_at val and ARGV.delete_at val) : default
16
+ if @cli.switches['help']
17
+ puts @cli.help_text
18
+ exit
19
+ elsif @cli.switches['version']
20
+ puts @cli.name + ' ' + FossGit.version
21
+ elsif @cli.switches['text-export']
22
+ system @fg.text_export_command
23
+ exit
24
+ else
25
+ if remotes = @cli.get_option('remotes')
26
+ remotes = remotes.split ','
60
27
  end
61
- end
62
28
 
63
- def option_switch? long_name
64
- ARGV.delete "-#{long_name[0]}" or ARGV.delete "--#{long_name}"
65
- end
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
- name = File.basename $0
78
-
79
- help = <<-EOF
80
-
81
- FossGit provides a simple tool for creating Git mirrors of Fossil
82
- repositories. To use it, you need:
83
-
84
- 1. both Fossil SCM and Git installed
85
- 2. a Fossil repository to mirror with an open checkout
86
- 3. a Git repository to use as a mirror
87
-
88
- USAGE: #{name} -h
89
- #{name} [-c <CHECKOUT>] [-l] <GITREPO>
90
- #{name} -t
91
-
92
- By default, when exporting to local Git repository GITREPO, #{name}
93
- attempts to push updates to a configured upstream Git repository. It
94
- harmlessly fails to push if no upstream repository is configured for the
95
- local Git repository.
96
-
97
- OPTIONS/ARGUMENTS:
98
-
99
- -h Display this help text and exit, ignoring all other
100
- arguments.
101
-
102
- -c CHECKOUT Specify the location of your Fossil repository's open
103
- checkout, CHECKOUT. This is optional; you may simply use
104
- this tool from within an open checkout of your Fossil
105
- repository instead.
29
+ ### NO MORE OPTION PARSING
106
30
 
107
- -l Perform local-only mirror operations, without trying to
108
- push Git updates to a remote repository. By default,
109
- #{name} tries to push to an upstream Git repository
110
- whenever it exports from Fossil to Git.
31
+ gitrepo = (@cli.args.shift or @cli.config['gitrepo'])
111
32
 
112
- -t Dump export to STDOUT rather than sending it to Git.
113
- This overrides the `-l` option and GITREPO argument, if
114
- present.
115
-
116
- GITREPO Specify the location of your local Git repository.
117
-
118
- EXAMPLES:
119
-
120
- $ fossgit -h
121
-
122
- $ fossgit -c ~/fossil_checkouts/projectname ~/git/projectname
123
-
124
- $ cd ~/fossil_checkouts/projectname && fossgit ~/git/projectname
125
-
126
- EOF
127
-
128
- if option_switch? 'help'
129
- puts help
130
- exit
131
- elsif option_switch? 'version'
132
- puts [name, FossGit.version].join ' '
133
- elsif option_switch? 'text-export'
134
- puts `#{fossil_command}|#{sed_command}`
135
- exit
136
- else
137
- command_line = mirror_command
138
- command_line << push_command unless option_switch? 'local'
33
+ unless remotes or @cli.switches['local']
34
+ if @cli.switches['all']
35
+ remotes = @fg.git_remotes(gitrepo)
36
+ elsif @cli.remotes and not @cli.switches['newgit']
37
+ remotes = (@cli.remotes == 'all') ? @fg.git_remotes(gitrepo) : @cli.remotes
38
+ else
39
+ remotes = ['origin']
40
+ end
41
+ end
139
42
 
140
- git_path = ARGV.shift
43
+ hasgit = Dir.exist? gitrepo
141
44
 
142
- if git_path.to_s.empty?
45
+ if gitrepo.to_s.empty?
143
46
  STDERR.puts 'Error! No Git path provided.'
144
47
  exit!
145
- elsif Dir.exist? git_path
146
- Dir.chdir git_path
48
+ elsif @cli.switches['newgit'] and gitrepo
49
+ if hasgit
50
+ STDERR.puts %Q{Error! Directory "#{gitrepo}" already exists.}
51
+ exit!
52
+ elsif Dir.mkdir gitrepo
53
+ Dir.chdir(gitrepo)
54
+
55
+ if `git init`.empty?
56
+ STDERR.puts %{Error! Cannot init Git within "#{gitrepo}".}
57
+ exit!
58
+ end
59
+ else
60
+ STDERR.puts %Q{Error! Cannot create directory "#{gitrepo}".}
61
+ exit!
62
+ end
63
+ elsif @cli.switches['newgit']
64
+ STDERR.puts %Q{Error! Name for new Git repository unknown.}
65
+ exit!
66
+ elsif hasgit
67
+ Dir.chdir gitrepo
147
68
  else
148
- STDERR.puts %Q{Error! Invalid Git path "#{git_path}" provided.}
69
+ STDERR.puts %Q{Error! Invalid Git path "#{gitrepo}" provided.}
149
70
  exit!
150
71
  end
151
72
 
152
73
  if system 'git status'
153
- system command_line
74
+ if @cli.switches['local']
75
+ system @fg.mirror_command
76
+ elsif remotes.empty?
77
+ STDERR.print %Q{Error! Git repository "#{Dir.pwd}" has no remotes.}
78
+ exit!
79
+ else
80
+ @fg.push_remote_list! remotes
81
+ end
154
82
  else
155
83
  STDERR.print %Q{Error! Invalid Git repository "#{Dir.pwd}" provided.}
156
84
  exit!
data/lib/fossgit.rb CHANGED
@@ -1,5 +1,114 @@
1
+ require 'yaml'
2
+
1
3
  class FossGit
4
+ attr_reader :checkout_path
5
+ attr_reader :fossil_repository
6
+ attr_accessor :project_name
7
+
8
+ def initialize checkout_path=''
9
+ @checkout_path = checkout_path
10
+ @checkout_path = get_element_matching :'local-root'
11
+
12
+ @fossil_repository = get_repository_path
13
+
14
+ @project_name = get_project_name
15
+ end
16
+
2
17
  def self.version
3
- '1.0.0'
18
+ '1.2.1'
19
+ end
20
+
21
+ def fossil_marks
22
+ File.join checkout_path, 'fossil.marks'
23
+ end
24
+
25
+ def git_marks
26
+ File.join checkout_path, 'git.marks'
27
+ end
28
+
29
+ def fossil_command
30
+ cmd = ['fossil export --git']
31
+
32
+ cmd << "--import-marks #{fossil_marks}" if update_export?
33
+ cmd << "--export-marks #{fossil_marks}"
34
+ cmd << fossil_repository
35
+
36
+ cmd.join ' '
37
+ end
38
+
39
+ def push_command gitremote
40
+ "; git checkout trunk; git push --all #{gitremote}"
41
+ end
42
+
43
+ def git_command
44
+ cmd = ['git fast-import']
45
+
46
+ cmd << "--import-marks=#{git_marks}" if update_export?
47
+ cmd << "--export-marks=#{git_marks}"
48
+
49
+ cmd.join ' '
50
+ end
51
+
52
+ def sed_command
53
+ # legacy fix for a bug in an old Fossil version's Git-export
54
+ %q{sed 's/^\(committer \+\)\([^ ]\+@[^ ]\+\)\( *<\)\(\w\+\)\(>.*\)$/\1\4\3\2\5/'}
55
+ end
56
+
57
+ def mirror_command
58
+ [fossil_command, sed_command, git_command].join '|'
59
+ end
60
+
61
+ def push_mirror_command gitremote
62
+ mirror_command + push_command(gitremote)
63
+ end
64
+
65
+ def push_remote_list! remote_list
66
+ remote_list.each do |gitremote|
67
+ puts "PUSH TO: #{gitremote}"
68
+ system push_mirror_command(gitremote)
69
+ end
70
+ end
71
+
72
+ def text_export_command
73
+ [fossil_command, sed_command].join '|'
74
+ end
75
+
76
+ def update_export?
77
+ File.exist? git_marks and File.exist? fossil_marks
78
+ end
79
+
80
+ def git_remotes gitpath
81
+ Dir.chdir gitpath do
82
+ `git remote`.split "\n"
83
+ end
84
+ end
85
+
86
+ private
87
+
88
+ def get_project_name
89
+ fossil_info = YAML.load `fossil info | head -n 1`
90
+ name = fossil_info ? fossil_info['project-name'] : fossil_info
91
+ name if not name.eql? '<unnamed>'
92
+ end
93
+
94
+ def get_repository_path
95
+ File.absolute_path get_element_matching :repository
96
+ end
97
+
98
+ def get_element_matching key
99
+ key_regex = /^#{key}: +/
100
+ fossil_status.select {|line| line.match key_regex }.first.sub key_regex, ''
101
+ end
102
+
103
+ def fossil_status
104
+ Dir.chdir checkout_path
105
+
106
+ stat = `fossil status`
107
+
108
+ if stat.size > 0
109
+ stat.split "\n"
110
+ else
111
+ raise ArgumentError, "#{checkout_path} is not a valid checkout path"
112
+ end
4
113
  end
5
114
  end
@@ -0,0 +1,185 @@
1
+ require 'yaml'
2
+
3
+ class CLI
4
+ attr_accessor :args, :config, :name, :switches
5
+
6
+ def initialize args=[], cliname='fossgit', filename='.fossgit'
7
+ @args = args
8
+ @config = Hash.new
9
+ @name = cliname
10
+
11
+ @config_filename = filename
12
+ @home_config_file = File.join(Dir.home, @config_filename)
13
+
14
+ configure @config_filename
15
+
16
+ @switches = Hash.new
17
+ end
18
+
19
+ def configure file=@config_filename
20
+ load_home_config
21
+ load_local_config file
22
+ end
23
+
24
+ def load_home_config
25
+ if File.exist? @home_config_file
26
+ @config = YAML.load_file @home_config_file
27
+ end
28
+ end
29
+
30
+ def load_local_config file=@config_filename
31
+ if File.exist? file
32
+ YAML.load_file(file).tap do |local|
33
+ local.each_key {|k| @config[k] = local[k] }
34
+ end
35
+ end
36
+ end
37
+
38
+ def remotes
39
+ config['remotes']
40
+ end
41
+
42
+ def remotes= gitremotes
43
+ config['remotes'] = gitremotes
44
+ end
45
+
46
+ def help_text
47
+ help = <<-EOF
48
+
49
+ FossGit mirrors Fossil repositories to Git repositories. You need:
50
+
51
+ 1. both Fossil SCM and Git installed
52
+ 2. a Fossil repository with an open checkout to export
53
+ 3. a Git repository to use as a mirror
54
+
55
+ USAGE: #{name} [-h | -v | [-c <CHECKOUT>] -t]
56
+ #{name} [-c <CHECKOUT>] [-a | -r REMOTE | -l] [[-n] GITREPO]
57
+
58
+ By default, when exporting to local Git repository GITREPO, #{name}
59
+ attempts to push updates to a configured upstream Git repository. It
60
+ should harmlessly fail to push if there is no upstream repository
61
+ configured for the local Git repository. If there is no GITREPO in
62
+ configuration (see CONFIG below), you must specify GITREPO when using
63
+ #{name} to mirror your Fossil repository.
64
+
65
+ OPTIONS/ARGUMENTS:
66
+
67
+ -h | --help
68
+
69
+ Display this help text and exit, ignoring all other arguments.
70
+
71
+ -a | --all
72
+
73
+ Push to all configured remotes for the target Git repository.
74
+ Default is to push only to the configured "origin" remote.
75
+
76
+ -c <CHECKOUT> | --checkout <CHECKOUT>
77
+
78
+ Specify CHECKOUT, your Fossil repository's checkout location.
79
+ This is optional; you may simply use this tool from within an
80
+ open checkout of your Fossil repository instead.
81
+
82
+ -l | --local
83
+
84
+ Perform local-only mirror operations without pushing to a remote
85
+ Git repository. By default, #{name} pushes to an upstream Git
86
+ repository whenever it exports from Fossil to Git.
87
+
88
+ -n | --newgit
89
+
90
+ Create a local Git repository mirror when it does not already
91
+ exist. Use this option from the Fossil repository's directory
92
+ hierarchy root and specify the Git repository's location as for
93
+ updating a mirror via config file, GITREPO argument, or Fossil
94
+ project-name setting in `fossil info` output.
95
+
96
+ -r | --remotes <COMMA,SEPARATED,REMOTES>
97
+
98
+ Specify which of the Git mirror's configured remotes to push in a
99
+ comma separated list with no spaces. This overrides `--all`.
100
+
101
+ -t | --text-export
102
+
103
+ Dump export to STDOUT as text rather than sending it to Git.
104
+ This overrides the `-l` switch and GITREPO argument, if present.
105
+
106
+ -v | --version
107
+
108
+ Show FossGit version number.
109
+
110
+ GITREPO
111
+
112
+ Specify the location of the local Git mirror, if there is no
113
+ configuration file specification or to override configuration.
114
+
115
+ COMMAND EXAMPLES:
116
+
117
+ $ fossgit -h
118
+
119
+ $ fossgit -c ~/fossil_checkouts/projectname ~/git/projectname
120
+
121
+ $ cd ~/fossil_checkouts/projectname && fossgit ~/git/projectname
122
+
123
+ CONFIG:
124
+
125
+ A config file named ".fossgit" can be used to set #{name} defaults.
126
+
127
+ A universal config file can be placed in the home directory of the
128
+ user account that executes this command, in which case it will apply
129
+ every time that account executes #{name}. A config file can also be
130
+ placed in the root of an open Fossil repository, in which case it
131
+ will only apply when #{name} is used for that particular repository.
132
+ If both files exist, settings from both will be used, but where both
133
+ have the same setting the more specific config (in the project
134
+ directory) overrides the equivalent setting from the universal
135
+ config. This means a universal configuration can be used for the
136
+ most common case, but for specific projects that have different needs
137
+ you can place a config file the project repository.
138
+
139
+ These are the available configuration options:
140
+
141
+ * The "gitdir" setting can be used to specify a directory in which
142
+ Git repositories are kept. In this case, #{name} infers the Git
143
+ repository name from the "project-name" in "fossil info" output.
144
+
145
+ * The "gitrepo" setting can be used to specify the full path to a Git
146
+ repository, without letting #{name} try to infer the repository
147
+ name. This option overrides "gitdir" if both are set. It is
148
+ probably a bad idea to set "gitrepo" in a universal config. It is
149
+ intended to be set in a project-specific ".fossgit" file because
150
+ chaos may ensue if all Fossil repositories use the same "gitrepo".
151
+
152
+ * The "remotes" setting can be used to specify which of your Git
153
+ mirror's configured remotes you want to use when pushing from Git.
154
+ As with the -r command line option, you can list one remote or list
155
+ several as a comma-separated list with no spaces. The "remotes"
156
+ setting in a configuration file accepts the "all" value, equivalent
157
+ to the -a command line option.
158
+
159
+ CONFIG EXAMPLES:
160
+
161
+ gitdir: /home/username/fossrec/git
162
+
163
+ gitrepo: /home/username/fossrec
164
+
165
+ remotes: gitlab
166
+
167
+ EOF
168
+ end
169
+
170
+ def get_option long_name, default=nil
171
+ if val = (args.index "-#{long_name[0]}" or args.index "--#{long_name}")
172
+ return (args.delete_at val and args.delete_at val)
173
+ else
174
+ return default
175
+ end
176
+ end
177
+
178
+ def option_switch? long_name
179
+ args.delete "-#{long_name[0]}" or args.delete "--#{long_name}"
180
+ end
181
+
182
+ def parse_switches opts
183
+ opts.each {|opt| switches[opt] = option_switch? opt }
184
+ end
185
+ end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fossgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Perrin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-25 00:00:00.000000000 Z
11
+ date: 2019-07-31 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 project mirrors.\n"
15
14
  email: code@apotheon.net
16
15
  executables:
17
16
  - fossgit
@@ -22,21 +21,24 @@ files:
22
21
  - README.md
23
22
  - bin/fossgit
24
23
  - lib/fossgit.rb
24
+ - lib/fossgit/cli.rb
25
25
  homepage: https://fossrec.com/u/apotheon/fossgit
26
26
  licenses:
27
27
  - COIL
28
28
  metadata: {}
29
29
  post_install_message: |2
30
30
  Thank you for using FossGit. For it to work properly, you need to have the
31
- following software dependencies installed:
31
+ following external software dependencies installed:
32
32
 
33
33
  * Fossil SCM (the world's most decentralized SCM and DVCS)
34
34
  * Git (the world's most popular DVCS)
35
35
  * sed (standard on Unix-like systems)
36
36
 
37
- Run "fossgit -h" for usage information.
37
+ This update adds Git upstream push for all branches. Report bugs at:
38
38
 
39
- Version 1.0.0 of FossGit is dedicated to my wife. Happy holidays.
39
+ https://fossrec.com/u/apotheon/fossgit/index.cgi/reportlist
40
+
41
+ Run "fossgit -h" for usage and configuration information.
40
42
  rdoc_options: []
41
43
  require_paths:
42
44
  - lib
@@ -44,16 +46,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
44
46
  requirements:
45
47
  - - ">="
46
48
  - !ruby/object:Gem::Version
47
- version: 1.9.3
49
+ version: 2.4.5
48
50
  required_rubygems_version: !ruby/object:Gem::Requirement
49
51
  requirements:
50
52
  - - ">="
51
53
  - !ruby/object:Gem::Version
52
54
  version: '0'
53
55
  requirements: []
54
- rubyforge_project:
55
- rubygems_version: 2.4.5.1
56
- signing_key:
56
+ rubygems_version: 3.2.3
57
+ signing_key:
57
58
  specification_version: 4
58
59
  summary: 'FossGit: Mirror Fossil to Git.'
59
60
  test_files: []