update_repo 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d492231d540c9292da5e531ca9b8996b68b8b3cb
4
- data.tar.gz: beaeeb3862f562398e8f93da7092aedc791e4e42
3
+ metadata.gz: fe97d312b2d580418707a7a5e139b9ce446e2564
4
+ data.tar.gz: ea880a88cc78769ae33ab2f9cd13f88800243ff3
5
5
  SHA512:
6
- metadata.gz: 144c0bc9cc6b33131cdd46b0db1b8b2a3a9c42a03e0ba11d2303966510d449046fe6726ea3eabf4cb8eabadc76625cf83facf6b826cd834042fba5d9f302ac8e
7
- data.tar.gz: 961c1c5fc1cfca3db813f44ebc464911ea7d2fd4cf5a30ddc77380638da74ce2bcd565eb74841b45f9d00a9fda46cbcd63661bf0bacaae94299e1c195c4b259d
6
+ metadata.gz: bc289788fbb7460a45a18154ea271e5c1f24b71a17f533f26ebfc93a66f8c2c021fdb580fe165df8f17466bb2043a5a2e5a981f5ee08eeaf162a8a95148caf49
7
+ data.tar.gz: ebf55d5a2f734362bce499c0f87f7697f50fd98564f5ebdf0bfde257bdd6e12b82a23ce357ed1e1c8d0dbbb414a896fdef07baf827376f135f2ed414bced3335
data/README.md CHANGED
@@ -89,6 +89,8 @@ Options:
89
89
  Any older logs will be overwritten.
90
90
  -t, --timestamp Timestamp the logfile instead of overwriting. Does nothing unless the
91
91
  --log option is also specified.
92
+ -r, --dump-remote Create a dump to screen or log listing all the git remote URLS found in
93
+ the specified directories.
92
94
  -v, --version Print version and exit
93
95
  -h, --help Show this message
94
96
  ```
@@ -100,27 +102,25 @@ Add functionality, not in any specific order :
100
102
  - Improve the stats / info at end-of-job :
101
103
  * errors or connection problems `[IN PROGRESS]`
102
104
  * _more..._
103
- - Add command line options to override configuration, and even specify an alternate config file. Any options so specified will have precedence over settings specified in the configuration file.
105
+ - Add command line options to override configuration, and even specify an alternate config file. Any options so specified will have precedence over settings specified in the configuration file. `[IN PROGRESS]`
104
106
  - Add command line options for verbose or quiet, with same options in config file.
105
107
  - Add ability to specify a new directory (containing Git repos) to search from the command line, and optionally save this to the standard configuration.
106
108
  - Add new repo from the command line that will be cloned to the default repo directory and then updated as usual. Extra flag added for "add only, clone later" for offline use.
107
109
  - Add flag for 'default' repo directory (or another specific directory - if it does not already exist it will be created and added to the standard list) which will be used for new additions.
108
- - Add option to only display a (text) tree of the discovered git repositories, not updating them; Similar option to just dump a list of the remote git locations.
110
+ - Add option to only display a (text) tree of the discovered git repositories, not updating them.
109
111
  - Add Import & Export functionality :
110
- * ability to export a text dump of each repo location `[DONE]`
112
+ * ability to export a text dump of each repo location and remote as a CSV file. `[DONE]`
111
113
  * re-import the above dump on a different machine or after reinstall
112
114
  - Add option to use alternative git command if required, either globally or on a case-by-case basis (see also comments on 'variants' above). Currently the script just uses a blanket `git pull` command on all repositories.
113
- - Document configuration file format and options.
115
+ - Document configuration file format and options. `[IN PROGRESS]`
114
116
 
115
117
  Internal Changes and refactoring :
116
118
  - Add testing!
117
- - Refactor all command-line handling into a separate class and file
118
119
  - Error checking and reporting for the git processes `[IN PROGRESS]`
119
120
  - Improve error-checking and recovery while parsing the configuration file
120
121
  * Ignore and report invalid or missing directories
121
122
  * Add more failure cases, not all git errors fail with "fatal:"
122
123
  - Retry for connection issues etc (config setting).
123
- - Fix functionality so that command line options will override those in the config file
124
124
 
125
125
  [confoog]: http://confoog.seapagan.net
126
126
 
@@ -21,6 +21,7 @@ module UpdateRepo
21
21
  prefix: 'update_repo',
22
22
  autoload: true, autosave: false)
23
23
  @conf['cmd'] = temp_opt
24
+ check_params
24
25
  config_error unless @conf.status[:errors] == Status::INFO_FILE_LOADED
25
26
  end
26
27
 
@@ -51,7 +52,10 @@ module UpdateRepo
51
52
  # make sure the parameter combinations are valid
52
53
  def check_params
53
54
  if true_cmd(:dump) && true_cmd(:import)
54
- Trollop.die 'Sorry, you cannot specify both --dump and --import '.red
55
+ Trollop.die 'Sorry, you cannot specify --dump AND --import'.red
56
+ end
57
+ if true_cmd(:dump) && true_cmd(:dump_remote)
58
+ Trollop.die 'Sorry, you cannot specify --dump AND --dump-remote'.red
55
59
  end
56
60
  end
57
61
 
@@ -89,6 +93,7 @@ EOS
89
93
  # opt :import, "Import a previous dump of directories and Git repository URL's,\n(created using --dump) then proceed to clone them locally.", default: false
90
94
  opt :log, "Create a logfile of all program output to './update_repo.log'. Any older logs will be overwritten.", default: false
91
95
  opt :timestamp, 'Timestamp the logfile instead of overwriting. Does nothing unless the --log option is also specified.', default: false
96
+ opt :dump_remote, 'Create a dump to screen or log listing all the git remote URLS found in the specified directories.', default: false, short: 'r'
92
97
  # opt :quiet, 'Only minimal output to the terminal', default: false
93
98
  # opt :silent, 'Completely silent, no output to terminal at all.', default: false
94
99
  end
@@ -1,4 +1,4 @@
1
1
  module UpdateRepo
2
2
  # constant, current version of this Gem
3
- VERSION = '0.7.3'.freeze
3
+ VERSION = '0.8.0'.freeze
4
4
  end
data/lib/update_repo.rb CHANGED
@@ -40,7 +40,7 @@ module UpdateRepo
40
40
  # make sure we dont have bad cmd-line parameter combinations ...
41
41
  @cmd.check_params
42
42
  # print out our header unless we are dumping / importing ...
43
- no_header = cmd(:dump) || cmd(:import)
43
+ no_header = cmd(:dump) || cmd(:import) || cmd(:dump_remote)
44
44
  show_header unless no_header
45
45
  config['location'].each do |loc|
46
46
  recurse_dir(loc)
@@ -77,7 +77,7 @@ module UpdateRepo
77
77
  Dir.chdir(dirname) do
78
78
  Dir['**/'].each do |dir|
79
79
  next unless gitdir?(dir)
80
- if cmd(:dump)
80
+ if cmd(:dump) || cmd(:dump_remote)
81
81
  dump_repo(File.join(dirname, dir))
82
82
  else
83
83
  notexception?(dir) ? update_repo(dir) : skip_repo(dir)
@@ -187,10 +187,13 @@ module UpdateRepo
187
187
  end
188
188
  end
189
189
 
190
+ # this function will either dump out a CSV with the directory and remote,
191
+ # or just the remote depending if we called --dump or --dump-remote
190
192
  def dump_repo(dir)
191
193
  Dir.chdir(dir.chomp!('/')) do
192
194
  repo_url = `git config remote.origin.url`.chomp
193
- print_log "#{trunc_dir(dir, config['cmd'][:prune])},#{repo_url}\n"
195
+ print_log "#{trunc_dir(dir, config['cmd'][:prune])}," if cmd(:dump)
196
+ print_log "#{repo_url}\n"
194
197
  end
195
198
  end
196
199
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: update_repo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grant Ramsay