falkorlib 0.7.16 → 0.7.17

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: 5357864bd82cefc2a1c4f104374275a3ab7094c9
4
- data.tar.gz: 00a2932ff2fe26c8d60b36a6573b506e8f682016
3
+ metadata.gz: 603782c1cf39fcfe8dc3e2ce0a8163feb6f46ded
4
+ data.tar.gz: 5c4a70beeacca4445e86fac8768fd75bd354d6a2
5
5
  SHA512:
6
- metadata.gz: 40c6b160ea3cea3ae23916c5273312805633134f4795f90c9d6c482dbde39836046196d1831e18a358e4d1bb4d37d7387fd17a470cae9138b2e873ad55fea65c
7
- data.tar.gz: cef36b07f6538759a1973d1152b30349b393cb1da652ef785db092e254397098e676c2647d27b28680d563b8163664640b5055f8186625f77d83b7bace308936
6
+ metadata.gz: 4aa8e8563852b17a9d4dbf7e09bd430c3c18a3d0681df652ac2c4d03d412009364ea95259e4fb316a9f0ef0d321fa6f1e35d55395d1f51e66e022c9cebcc5e21
7
+ data.tar.gz: 15952d0e647dccf036b4d0db8b7829180ead265af2291535338d9de6f7c437b69dae1e15bc9e0bf4e6241dae7bc7475df6d9fcbe9562befc462b79f743cdc3bb
data/.travis.yml CHANGED
@@ -23,6 +23,7 @@ addons:
23
23
  - unzip
24
24
  - git
25
25
  - git-flow
26
+ - git-crypt
26
27
  hosts:
27
28
  - travis.dev
28
29
  before_install:
data/Gemfile CHANGED
@@ -8,7 +8,8 @@ end
8
8
 
9
9
  group :test do
10
10
  gem "simplecov", :require => false
11
- gem "rubocop", :require => false
11
+ gem "rubocop", ">= 0.49.0", :require => false
12
+ gem "ffi", ">= 1.9.24", :require => false
12
13
  end
13
14
 
14
15
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.7.16)
4
+ falkorlib (0.7.17)
5
5
  activesupport (~> 4.0)
6
6
  artii (>= 2.1)
7
7
  awesome_print (~> 1.2)
@@ -31,7 +31,7 @@ GEM
31
31
  addressable (2.5.0)
32
32
  public_suffix (~> 2.0, >= 2.0.2)
33
33
  artii (2.1.2)
34
- ast (2.3.0)
34
+ ast (2.4.0)
35
35
  awesome_print (1.7.0)
36
36
  backports (3.6.8)
37
37
  codeclimate-test-reporter (0.3.0)
@@ -49,7 +49,7 @@ GEM
49
49
  multipart-post (>= 1.2, < 3)
50
50
  faraday_middleware (0.10.1)
51
51
  faraday (>= 0.7.4, < 1.0)
52
- ffi (1.9.14)
52
+ ffi (1.9.25)
53
53
  gh (0.14.0)
54
54
  addressable
55
55
  backports
@@ -61,6 +61,7 @@ GEM
61
61
  hashr (0.0.22)
62
62
  highline (1.7.8)
63
63
  i18n (0.7.0)
64
+ jaro_winkler (1.5.1)
64
65
  json (1.8.6)
65
66
  launchy (2.4.3)
66
67
  addressable (~> 2.3)
@@ -74,9 +75,10 @@ GEM
74
75
  multipart-post (2.0.0)
75
76
  net-http-persistent (2.9.4)
76
77
  net-http-pipeline (1.0.1)
77
- parser (2.3.1.4)
78
- ast (~> 2.2)
79
- powerpack (0.1.1)
78
+ parallel (1.12.1)
79
+ parser (2.5.3.0)
80
+ ast (~> 2.4.0)
81
+ powerpack (0.1.2)
80
82
  pry (0.10.4)
81
83
  coderay (~> 1.1.0)
82
84
  method_source (~> 0.8.1)
@@ -85,7 +87,7 @@ GEM
85
87
  pusher-client (0.6.2)
86
88
  json
87
89
  websocket (~> 1.0)
88
- rainbow (2.1.0)
90
+ rainbow (3.0.0)
89
91
  rake (10.5.0)
90
92
  rspec (3.5.0)
91
93
  rspec-core (~> 3.5.0)
@@ -100,13 +102,15 @@ GEM
100
102
  diff-lcs (>= 1.2.0, < 2.0)
101
103
  rspec-support (~> 3.5.0)
102
104
  rspec-support (3.5.0)
103
- rubocop (0.45.0)
104
- parser (>= 2.3.1.1, < 3.0)
105
+ rubocop (0.57.2)
106
+ jaro_winkler (~> 1.5.1)
107
+ parallel (~> 1.10)
108
+ parser (>= 2.5)
105
109
  powerpack (~> 0.1)
106
- rainbow (>= 1.99.1, < 3.0)
110
+ rainbow (>= 2.2.2, < 4.0)
107
111
  ruby-progressbar (~> 1.7)
108
112
  unicode-display_width (~> 1.0, >= 1.0.1)
109
- ruby-progressbar (1.8.1)
113
+ ruby-progressbar (1.10.0)
110
114
  rubygems-tasks (0.2.4)
111
115
  safe_yaml (0.9.7)
112
116
  simplecov (0.8.2)
@@ -138,7 +142,7 @@ GEM
138
142
  ethon (>= 0.8.0)
139
143
  tzinfo (1.2.2)
140
144
  thread_safe (~> 0.1)
141
- unicode-display_width (1.1.1)
145
+ unicode-display_width (1.4.0)
142
146
  websocket (1.2.3)
143
147
  yard (0.9.12)
144
148
 
@@ -150,10 +154,11 @@ DEPENDENCIES
150
154
  bundler
151
155
  codeclimate-test-reporter (~> 0)
152
156
  falkorlib!
157
+ ffi (>= 1.9.24)
153
158
  pry
154
159
  rake
155
160
  rspec (~> 3.0)
156
- rubocop
161
+ rubocop (>= 0.49.0)
157
162
  rubygems-tasks (~> 0.2)
158
163
  simplecov
159
164
  travis (~> 1.6)
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Fri 2018-04-27 16:58 svarrette>
3
+ # Time-stamp: <Thu 2018-11-08 17:47 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Bootstrapping operations
6
6
  #
@@ -22,6 +22,22 @@ module FalkorLib #:nodoc:
22
22
 
23
23
  DEFAULTS =
24
24
  {
25
+ :gitcrypt => {
26
+ :owner => `git config user.signingKey`.chomp,
27
+ :subkeys => [],
28
+ :hooksdir => 'config/hooks',
29
+ :hook => 'pre-commit.git-crypt.sh',
30
+ :ulhpc => [
31
+ #'Ox5D08BCDD4F156AD7', # S. Varrette
32
+ '0x3F3242C5B34D98C2', # V. Plugaru
33
+ '0x6429C2514EBC4737', # S. Peter
34
+ '0x07FEA8BA69203C2D', # C. Parisot
35
+ '0x37183CEF550DF40B', # H. Cartiaux
36
+ ],
37
+ # :hooks => {
38
+ # :precommit => 'https://gist.github.com/848c82daa63710b6c132bb42029b30ef.git',
39
+ # },
40
+ },
25
41
  :motd => {
26
42
  :file => 'motd',
27
43
  :hostname => `hostname -f`.chomp,
@@ -140,6 +156,55 @@ module FalkorLib
140
156
 
141
157
  module_function
142
158
 
159
+ ###### makefile ######
160
+ # Supported options:
161
+ # * :master [string] git flow master/production branch
162
+ # * :develop [string] git flow development branch
163
+ # * :force [boolean] for overwritting
164
+ #......................................
165
+ def makefile(dir = Dir.pwd, options = {})
166
+ path = normalized_path(dir)
167
+ path = FalkorLib::Git.rootdir(path) if FalkorLib::Git.init?(path)
168
+ info "=> Setup a root repository makefile in '#{dir}'"
169
+ # Preparing submodule
170
+ submodules = {}
171
+ submodules['Makefiles'] = {
172
+ :url => 'https://github.com/Falkor/Makefiles.git',
173
+ :branch => 'devel'
174
+ }
175
+ FalkorLib::Git.submodule_init(path, submodules)
176
+ makefile = File.join(path, "Makefile")
177
+ if File.exist?( makefile )
178
+ puts " ... not overwriting the root Makefile which already exists"
179
+ else
180
+ src_makefile = File.join(path, FalkorLib.config.git[:submodulesdir],
181
+ 'Makefiles', 'repo', 'Makefile')
182
+ FileUtils.cp src_makefile, makefile
183
+ gitflow_branches = FalkorLib::Config::GitFlow::DEFAULTS[:branches]
184
+ if FalkorLib::GitFlow.init?(path)
185
+ [ :master, :develop ].each do |b|
186
+ gitflow_branches[t.to_sym] = FalkorLib::GitFlow.branches(b.to_sym)
187
+ end
188
+ end
189
+ unless options.nil?
190
+ [ :master, :develop ].each do |b|
191
+ gitflow_branches[b.to_sym] = options[b.to_sym] if options[b.to_sym]
192
+ end
193
+ end
194
+ info "adapting Makefile to the gitflow branches"
195
+ Dir.chdir( path ) do
196
+ run %(
197
+ sed -i '' \
198
+ -e \"s/^GITFLOW_BR_MASTER=production/GITFLOW_BR_MASTER=#{gitflow_branches[:master]}/\" \
199
+ -e \"s/^GITFLOW_BR_DEVELOP=devel/GITFLOW_BR_DEVELOP=#{gitflow_branches[:develop]}/\" \
200
+ Makefile
201
+ )
202
+ end
203
+ FalkorLib::Git.add(makefile, 'Initialize root Makefile for the repo')
204
+ end
205
+ end # makefile
206
+
207
+
143
208
  ###
144
209
  # Initialize a trash directory in path
145
210
  ##
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mon 2017-01-16 14:16 svarrette>
3
+ # Time-stamp: <Thu 2018-11-08 18:27 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Bootstrapping operations
6
6
  #
@@ -66,39 +66,14 @@ module FalkorLib
66
66
  FalkorLib::Git.init(path, options)
67
67
  end
68
68
  # === prepare Git submodules ===
69
- info " ==> prepare the relevant Git submodules"
70
69
  submodules = {}
71
70
  #'gitstats' => { :url => 'https://github.com/hoxu/gitstats.git' }
72
- # }
73
- if options[:make]
74
- submodules['Makefiles'] = {
75
- :url => 'https://github.com/Falkor/Makefiles.git',
76
- :branch => 'devel'
77
- }
71
+ unless submodules.empty?
72
+ info " ==> prepare the relevant Git submodules"
73
+ FalkorLib::Git.submodule_init(path, submodules)
78
74
  end
79
- FalkorLib::Git.submodule_init(path, submodules)
80
75
  # === Prepare root [M|R]akefile ===
81
- if options[:make]
82
- info " ==> prepare Root Makefile"
83
- makefile = File.join(path, "Makefile")
84
- if File.exist?( makefile )
85
- puts " ... not overwriting the root Makefile which already exists"
86
- else
87
- src_makefile = File.join(path, FalkorLib.config.git[:submodulesdir],
88
- 'Makefiles', 'repo', 'Makefile')
89
- FileUtils.cp src_makefile, makefile
90
- info "adapting Makefile to the gitflow branches"
91
- Dir.chdir( path ) do
92
- run %(
93
- sed -i '' \
94
- -e \"s/^GITFLOW_BR_MASTER=production/GITFLOW_BR_MASTER=#{gitflow_branches[:master]}/\" \
95
- -e \"s/^GITFLOW_BR_DEVELOP=devel/GITFLOW_BR_DEVELOP=#{gitflow_branches[:develop]}/\" \
96
- Makefile
97
- )
98
- end
99
- FalkorLib::Git.add(makefile, 'Initialize root Makefile for the repo')
100
- end
101
- end
76
+ FalkorLib::Bootstrap.makefile(path, gitflow_branches) if options[:make]
102
77
  if options[:rake]
103
78
  info " ==> prepare Root Rakefile"
104
79
  rakefile = File.join(path, "Rakefile")
@@ -147,7 +122,100 @@ module FalkorLib
147
122
  end
148
123
  end # repo
149
124
 
125
+ ###### gitcrypt ######
126
+ # Initialize git-crypt in the current directory
127
+ # Supported options:
128
+ # * :force [boolean] force overwritting
129
+ # * :owner [string] owner (GPG ID or email)
130
+ # * :keys [array] List of GPG IDs allowed to unlock the repository
131
+ # * :ulhpc [boolean] setup the repository for the ULHPC team
132
+ ##
133
+ def gitcrypt(dir = Dir.pwd, options = {})
134
+ path = normalized_path(dir)
135
+ unless File.directory?(path)
136
+ warning "The directory '#{path}' does not exist yet."
137
+ warning 'Do you want to create (and git init) this directory?'
138
+ really_continue?
139
+ run %(mkdir -p #{path})
140
+ FalkorLib::Git.init(path)
141
+ end
142
+ error "Not a git-ready directory" unless FalkorLib::Git.init?(path)
143
+ rootdir = FalkorLib::Git.rootdir(path)
144
+ config = FalkorLib::Config::Bootstrap::DEFAULTS[:gitcrypt].clone
145
+ info "about to initialize Git crypt for the repository '#{rootdir}'"
146
+ really_continue?
147
+ config[:owner] = (options[:owner]) ? options[:owner] : ask("\tEmail or (better) GPG ID of the owner of the git-crypt (root) vault", config[:owner])
148
+ [ :hooksdir ].each do |k|
149
+ config[k] = (options[k]) ? options[k] : ask("\t#{k.capitalize}", config[k])
150
+ end
151
+ #puts config.to_yaml
152
+ if File.exists?(File.join(rootdir, '.git/git-crypt/keys/default'))
153
+ warning "git-crypt has already been initialised in '#{rootdir}'"
154
+ else
155
+ Dir.chdir( rootdir ) do
156
+ run %( git crypt init )
157
+ if config[:owner]
158
+ info "setup owner of the git-crypt vault to '#{config[:owner]}'"
159
+ run %( gpg --list-key #{config[:owner]} | grep uid| head -n1)
160
+ run %( git crypt add-gpg-user #{config[:owner]} )
161
+ end
162
+ end
163
+ end
164
+ # Bootstrap the directory
165
+ gitattributes = File.join(rootdir, '.gitattributes')
166
+ if File.exists?(gitattributes)
167
+ puts " ... '.gitattributes' file already exists"
168
+ else
169
+ templatedir = File.join( FalkorLib.templates, 'git-crypt')
170
+ init_from_template(templatedir, rootdir, {},
171
+ :no_interaction => true,
172
+ :no_commit => false)
173
+ FalkorLib::Git.add(gitattributes, 'Initialize .gitattributes for git-crypt')
174
+ end
175
+
176
+ git_hooksdir = File.join(rootdir, '.git', 'hooks')
177
+ precommit_hook = File.join(git_hooksdir, 'pre-commit')
178
+ src_git_hooksdir = File.join(rootdir, config[:hooksdir])
179
+ src_precommit_hook = File.join(src_git_hooksdir, config[:hook])
180
+ if File.exists?(File.join(rootdir, config[:hook]))
181
+ Dir.chdir( rootdir ) do
182
+ run %(mkdir -p #{config[:hooksdir]} )
183
+ unless File.exists?(src_precommit_hook)
184
+ run %(mv #{config[:hook]} #{config[:hooksdir]}/ )
185
+ run %(chmod +x #{config[:hooksdir]}/#{config[:hook]})
186
+ FalkorLib::Git.add(src_precommit_hook, 'pre-commit hook for git-crypt')
187
+ end
188
+ run %(rm -f #{config[:hook]} ) if File.exists?(File.join(rootdir, config[:hook]))
189
+ end
190
+ end
191
+ # Pre-commit hook
192
+ unless File.exist?(precommit_hook)
193
+ info "=> bootstrapping special Git pre-commit hook for git-crypt"
194
+ relative_src_hooksdir = Pathname.new( File.realpath( src_git_hooksdir )).relative_path_from Pathname.new( git_hooksdir )
195
+ Dir.chdir( git_hooksdir ) do
196
+ run %(ln -s #{relative_src_hooksdir}/#{config[:hook]} pre-commit)
197
+ end
198
+ end
199
+ gpgkeys = []
200
+ gpgkeys = config[:ulhpc] if options[:ulhpc]
201
+ gpgkeys = options[:keys] if options[:keys]
202
+ unless gpgkeys.empty?
203
+ warning "About to allow the following GPG IDs to unlock the git-crypt vault"
204
+ puts gpgkeys.to_yaml
205
+ really_continue?
206
+ end
207
+ gpgkeys.each do |k|
208
+ Dir.chdir( rootdir ) do
209
+ info "allow GPG ID '#{k}' to unlock the git-crypt vault"
210
+ run %( gpg --list-key #{k} | grep uid| head -n1)
211
+ run %( git crypt add-gpg-user #{k} )
212
+ end
213
+ end
214
+
215
+
216
+
150
217
 
218
+ end # gitcrypt
151
219
 
152
220
  end # module Bootstrap
153
221
  end # module FalkorLib
data/lib/falkorlib/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Fri 2018-04-27 13:39 svarrette>
3
+ # Time-stamp: <Thu 2018-11-08 17:28 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the CLI
6
6
  #
@@ -14,6 +14,7 @@ require 'falkorlib'
14
14
 
15
15
  require 'falkorlib/cli/new'
16
16
  require 'falkorlib/cli/link'
17
+ require 'falkorlib/cli/make'
17
18
 
18
19
 
19
20
 
@@ -67,6 +68,19 @@ CONFIG_LONG_DESC
67
68
 
68
69
  #map %w[--help -h] => :help
69
70
 
71
+ ###### gitcrypt ######
72
+ method_option :owner, :aliases => '-o',
73
+ :desc => "Email or (better) GPG ID of the owner of the git-crypt (root) vault"
74
+ method_option :ulhpc, :aliases => '-u', :type => :boolean,
75
+ :desc => "Bootstrap git-crypt for the UL HPC team"
76
+ method_option :keys, :type => :array, :aliases => [ '--gpgkeys', '-k' ],
77
+ :desc => "(space separated) List of GPG IDs allowed to unlock the repository"
78
+ #......................................
79
+ desc "gitcrypt <PATH> [options]", "Initialize git-crypt for the current repository"
80
+ def gitcrypt(path = '.')
81
+ FalkorLib::Bootstrap.gitcrypt(path, options)
82
+ end # gitcrypt
83
+
70
84
  ###### init ######
71
85
  desc "init <PATH> [options]", "Bootstrap a Git Repository"
72
86
  long_desc <<-INIT_LONG_DESC
@@ -0,0 +1,56 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Thu 2018-11-08 16:50 svarrette>
4
+ ################################################################################
5
+
6
+ require 'thor'
7
+ require 'falkorlib'
8
+ #require 'falkorlib/cli/init/repo'
9
+ #require "falkorlib/bootstrap"
10
+
11
+ module FalkorLib
12
+ module CLI
13
+ # Thor class for symlink creation
14
+ class Make < ::Thor
15
+
16
+ include FalkorLib::Common
17
+
18
+ ###### commands ######
19
+ desc "commands", "Lists all available commands", :hide => true
20
+ def commands
21
+ puts Make.all_commands.keys.sort - [ 'commands' ]
22
+ end
23
+
24
+ ###### repo ######
25
+ method_option :master, :aliases => ['--production', '-m', '-p'],
26
+ :desc => 'Git flow master/production branch'
27
+ method_option :develop, :aliases => ['--devel', '-d'],
28
+ :desc => 'Git flow development branch'
29
+ #......................................
30
+ desc "repo", "Create a root Makefile piloting repository operations"
31
+ def repo(dir = Dir.pwd)
32
+ FalkorLib::Bootstrap.makefile(dir, options)
33
+ end # repo
34
+
35
+
36
+ ###### latex ######
37
+ desc "latex", "Symlink to a Makefile to compile LaTeX documents"
38
+ def latex(dir = Dir.pwd)
39
+ FalkorLib::Bootstrap::Link.makefile(dir, :latex => true)
40
+ end # latex
41
+
42
+ ##### gnuplot #####
43
+ desc "gnuplot", "Symlink to a Makefile to compile GnuPlot scripts"
44
+ def gnuplot(dir = Dir.pwd)
45
+ FalkorLib::Bootstrap::Link.makefile(dir, :gnuplot => true)
46
+ end # gnuplot
47
+
48
+ ##### generic #####
49
+ desc "generic", "Symlink to Generic Makefile for sub directory"
50
+ def generic(dir = Dir.pwd)
51
+ FalkorLib::Bootstrap::Link.makefile(dir, :generic => true)
52
+ end # generic
53
+
54
+ end # class Make
55
+ end # module CLI
56
+ end # module FalkorLib
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Mon 2017-01-16 23:52 svarrette>
3
+ # Time-stamp: <Thu 2018-11-08 17:01 svarrette>
4
4
  ################################################################################
5
5
 
6
6
  require 'thor'
@@ -101,6 +101,31 @@ By default, NAME is '.' meaning that the repository will be initialized in the c
101
101
  FalkorLib::Bootstrap.license(path, license, '', options)
102
102
  end # license
103
103
 
104
+ ##### make ######
105
+ method_option :repo, :type => :boolean, :aliases => '-r',
106
+ :desc => "Create a root Makefile piloting repository operations"
107
+ method_option :latex, :type => :boolean, :aliases => '-l',
108
+ :desc => "Makefile to compile LaTeX documents"
109
+ method_option :gnuplot, :type => :boolean, :aliases => ['--plot', '-p'],
110
+ :desc => "Makefile to compile GnuPlot scripts"
111
+ method_option :generic, :type => :boolean, :aliases => '-g',
112
+ :desc => "Generic Makefile for sub directory"
113
+ method_option :images, :type => :boolean, :aliases => [ '-i', '--img' ],
114
+ :desc => "Makefile to optimize images"
115
+ method_option :src, :type => :boolean, :aliases => [ '--src', '-s' ],
116
+ :desc => "Path to Falkor's Makefile for latex_src"
117
+ #......................................
118
+ desc "make [options]", "Initiate one of Falkor's Makefile"
119
+ def make(dir = Dir.pwd)
120
+ if options[:repo]
121
+ FalkorLib::Bootstrap.makefile(dir)
122
+ elsif (options[:latex] or options[:gnuplot] or options[:generic] or options[:images] or options[:src])
123
+ FalkorLib::Bootstrap::Link.makefile(dir, options)
124
+ else
125
+ FalkorLib::Common.error 'Kindly precize the type of Makefile you which to create'
126
+ end
127
+ end # make
128
+
104
129
 
105
130
  ###### slides ######
106
131
  #......................................
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
19
19
  # MAJOR: Defines the major version
20
20
  # MINOR: Defines the minor version
21
21
  # PATCH: Defines the patch version
22
- MAJOR, MINOR, PATCH = 0, 7, 16
22
+ MAJOR, MINOR, PATCH = 0, 7, 17
23
23
 
24
24
  module_function
25
25
 
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # bootstrap_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Mon 2017-01-16 11:30 svarrette>
5
+ # Time-stamp: <Thu 2018-11-08 16:26 svarrette>
6
6
  #
7
7
  # @description Check the basic Bootstrapping operations
8
8
  #
@@ -37,7 +37,7 @@ describe FalkorLib::Bootstrap do
37
37
  end
38
38
 
39
39
  [ :without_git, :with_git ].each do |ctx|
40
- # [ :with_git ].each do |ctx|
40
+ # [ :with_git ].each do |ctx|
41
41
  dir = dirs[ctx]
42
42
  #############################################################
43
43
  context "bootstrap/base (#{ctx}) within temporary directory '#{dir}'" do
@@ -49,8 +49,16 @@ describe FalkorLib::Bootstrap do
49
49
  t = FalkorLib::Git.init?(dir)
50
50
  expect(t).to be true
51
51
  end
52
+
53
+ #### root Makefile creation #########
54
+ it "#makefile -- bootstrap root makefile" do
55
+ c = FalkorLib::Bootstrap.makefile(dir)
56
+ t = File.exists?( File.join(dir, 'Makefile'))
57
+ end
58
+
52
59
  end
53
60
 
61
+
54
62
  #### Trash creation #########
55
63
  it "#trash" do
56
64
  c = FalkorLib::Bootstrap.trash(dir)
@@ -146,6 +154,36 @@ describe FalkorLib::Bootstrap do
146
154
  end
147
155
  end
148
156
 
157
+ if ctx == :without_git
158
+ it "#repo -- bootstrap a new repository" do
159
+ c = FalkorLib::Bootstrap.repo(dir, { :no_interaction => true, :make => true, :git_flow => false })
160
+ [ 'Makefile', 'VERSION', 'README.md' ].each do |f|
161
+ expect(File).to exist( File.join(dir, f))
162
+ end
163
+ end
164
+ end
165
+
166
+ if ctx == :with_git
167
+ it "#gitcrypt -- owner is empty" do
168
+ c = FalkorLib::Bootstrap.gitcrypt(dir, { :owner => '', :no_interaction => true })
169
+ [ '.git-crypt' ].each do |d|
170
+ expect(File.directory?(File.join(dir, d))).to be false
171
+ end
172
+ expect(File).to exist( File.join(dir, '.gitattributes'))
173
+ expect(File).to exist( File.join(dir, '.git', 'git-crypt', 'keys', 'default'))
174
+ expect(File).to exist( File.join(dir, FalkorLib::Config::Bootstrap::DEFAULTS[:gitcrypt][:hooksdir], FalkorLib::Config::Bootstrap::DEFAULTS[:gitcrypt][:hook]))
175
+ expect(File).to exist( File.join(dir, '.git','hooks','pre-commit'))
176
+ end
177
+ # it "#gitcrypt -- owner" do
178
+ # c = FalkorLib::Bootstrap.gitcrypt(dir, { :no_interaction => true })
179
+ # [ '.git-crypt' ].each do |d|
180
+ # expect(File.directory?(File.join(dir, d))).to be true
181
+ # end
182
+ # #expect(File).to exist( File.join(dir, '.git-crypt', 'keys', 'default', '0', '*.gpg'))
183
+ # # TODO check gpg file
184
+ # end
185
+ end
186
+
149
187
 
150
188
  end # context "bootstrap/base"
151
189
  end # each
@@ -0,0 +1,10 @@
1
+ # -*- mode: conf -*-
2
+ #
3
+ # specify which files to encrypt using [git-crypt](https://www.agwa.name/projects/git-crypt/)
4
+ #
5
+
6
+ # Certificate private keys
7
+ # *.key filter=git-crypt diff=git-crypt
8
+ # Private document/folders
9
+ # *PRIVATE* filter=git-crypt diff=git-crypt
10
+ # subfolder/**/* filter=git-crypt diff=git-crypt
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+ ################################################################################
3
+ # See <https://gist.github.com/Falkor/848c82daa63710b6c132bb42029b30ef>
4
+ # Pre-commit hook to avoid accidentally adding unencrypted files with [git-crypt](https://www.agwa.name/projects/git-crypt/)
5
+ # Fix to [Issue #45](https://github.com/AGWA/git-crypt/issues/45)
6
+ #
7
+ # Usage:
8
+ # $> cd /path/to/repository
9
+ # $> git-crypt init
10
+ # $> curl <url/to/this/raw/gist> -o .git/hooks/pre-commit
11
+ # $> chmod +x .git/hooks/pre-commit
12
+ #
13
+ # Otherwise, you might want to add it as a git submodule, using:
14
+ # $> git submodule add https://gist.github.com/848c82daa63710b6c132bb42029b30ef.git config/hooks/pre-commit.git-crypt
15
+ # $> cd .git/hooks
16
+ # $> ln -s ../../config/hooks/pre-commit.git-crypt/pre-commit.git-crypt.sh pre-commit
17
+ #
18
+
19
+ if [ -d .git-crypt ]; then
20
+ STAGED_FILES=$(git diff --cached --name-status | awk '$1 != "D" { print $2 }' | xargs echo)
21
+ if [ -n "${STAGED_FILES}" ]; then
22
+ git-crypt status ${STAGED_FILES} &>/dev/null
23
+ if [[ $? -ne 0 ]]; then
24
+ git-crypt status -e ${STAGED_FILES}
25
+ echo '/!\ You should have first unlocked your repository BEFORE staging the above file(s)'
26
+ echo '/!\ Proceed now as follows:'
27
+ echo -e "\t git unstage ${STAGED_FILES}"
28
+ echo -e "\t git crypt unlock"
29
+ echo -e "\t git add ${STAGED_FILES}"
30
+ exit 1
31
+ fi
32
+ fi
33
+ fi
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falkorlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.16
4
+ version: 0.7.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -422,6 +422,7 @@ files:
422
422
  - lib/falkorlib/cli.rb
423
423
  - lib/falkorlib/cli/config.rb
424
424
  - lib/falkorlib/cli/link.rb
425
+ - lib/falkorlib/cli/make.rb
425
426
  - lib/falkorlib/cli/new.rb
426
427
  - lib/falkorlib/common.rb
427
428
  - lib/falkorlib/config.rb
@@ -484,6 +485,8 @@ files:
484
485
  - templates/gems/lib/sysadmin-warrior/loader.rb
485
486
  - templates/gems/lib/sysadmin-warrior/version.rb
486
487
  - templates/gems/sysadmin-warrior.gemspec
488
+ - templates/git-crypt/.gitattributes
489
+ - templates/git-crypt/pre-commit.git-crypt.sh
487
490
  - templates/latex/.gitignore
488
491
  - templates/latex/acm/ACM-Reference-Format.bst
489
492
  - templates/latex/acm/acmart.cls