Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Support erb in config file && allow silent branch-failure #4

Open
wants to merge 2 commits into from

2 participants

Pete Hamilton Olivier Gonzalez
Pete Hamilton

Allows injection of API key from environment using

<%= ENV['GEMNASIUM_API_KEY'] %>

If you want the config file versioned.

Also allows you to prevent an error-return if the current branch is not the specified gemnasium one.

Olivier Gonzalez
Owner

Thanks for providing this. Can you please add some tests too?

You may also avoid bumping the version, we'll do it when releasing the gem and updating the changelog accordingly.
And why bumping to 2.0.2? There is no 2.0.1 release. Please revert this.

Pete Hamilton - Support erb in YAML config file
- Allow ignoring of pushes on untracked branches

Allows injection of API key from environment using
<%= ENV['GEMNASIUM_API_KEY'] %>
7fe75d5
Pete Hamilton

Sure, apologies for version bump, wasn't really thinking. Will update with tests shortly.

Olivier Gonzalez
Owner

Getting close :) Can you please update the gemnasium_spec.rb too ? to ensure command behavior on a non tracked branch with the --ignore-branch option

Skip Baney twelvelabs referenced this pull request from a commit in voxmedia/gemnasium-gem
Skip Baney Add an --ignore-branch option for 'gemnasium push'
Mostly copied from gemnasium#4, but renamed and including additional requested specs.
7b427aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

May 06, 2013
Pete Hamilton - Support erb in YAML config file
- Allow ignoring of pushes on untracked branches

Allows injection of API key from environment using
<%= ENV['GEMNASIUM_API_KEY'] %>
7fe75d5
Pete Hamilton Added test for --silent-branch option 586fee6
This page is out of date. Refresh to see the latest.
10  lib/gemnasium.rb
@@ -14,7 +14,13 @@ def push options
14 14
       @config = load_config(options[:project_path])
15 15
 
16 16
       unless current_branch == @config.project_branch
17  
-        quit_because_of("Gemnasium : Dependency files updated but not on tracked branch (#{@config.project_branch}), ignoring...\n")
  17
+        message = "Gemnasium : Dependency files updated but not on tracked branch (#{@config.project_branch}), ignoring...\n"
  18
+        if options[:silent_branch]
  19
+          notify message, :blue
  20
+          return
  21
+        else
  22
+          quit_because_of(message)
  23
+        end
18 24
       end
19 25
 
20 26
       dependency_files_hashes = DependencyFiles.get_sha1s_hash(options[:project_path])
@@ -223,4 +229,4 @@ def copy_template(file, target_path)
223 229
       false
224 230
     end
225 231
   end
226  
-end
  232
+end
5  lib/gemnasium/configuration.rb
... ...
@@ -1,4 +1,5 @@
1 1
 require 'yaml'
  2
+require 'erb'
2 3
 
3 4
 module Gemnasium
4 5
   class Configuration
@@ -14,7 +15,7 @@ class Configuration
14 15
     def initialize config_file
15 16
       raise Errno::ENOENT, "Configuration file (#{config_file}) does not exist.\nPlease run `gemnasium install`." unless File.file?(config_file)
16 17
 
17  
-      config_hash = DEFAULT_CONFIG.merge!(YAML.load_file(config_file))
  18
+      config_hash = DEFAULT_CONFIG.merge!(YAML.load(ERB.new(File.read(config_file)).result))
18 19
       config_hash.each do |k, v|
19 20
         writer_method = "#{k}="
20 21
         if respond_to?(writer_method)
@@ -55,4 +56,4 @@ def convert_ignored_paths_to_regexp(paths)
55 56
       end
56 57
     end
57 58
   end
58  
-end
  59
+end
6  lib/gemnasium/options.rb
@@ -62,6 +62,10 @@ def self.parse args
62 62
         'push'    => OptionParser.new do |opts|
63 63
           opts.banner = 'Usage: gemnasium push'
64 64
 
  65
+          opts.on '--silent-branch', 'Ignore untracked branches' do
  66
+            options[:silent_branch] = true
  67
+          end
  68
+
65 69
           opts.on '-h', '--help', 'Display this message' do
66 70
             options[:show_help] = true
67 71
           end
@@ -81,4 +85,4 @@ def self.parse args
81 85
       return options, parser
82 86
     end
83 87
   end
84  
-end
  88
+end
9  spec/gemnasium/options_spec.rb
@@ -104,7 +104,14 @@
104 104
             expect(options).to eql({ command: 'push' })
105 105
           end
106 106
         end
  107
+
  108
+        context 'with silent branch options' do
  109
+          it 'correctly set the options' do
  110
+            options, parser = Gemnasium::Options.parse ['push', '--silent-branch']
  111
+            expect(options).to eql({ command: 'push', silent_branch: true })
  112
+          end
  113
+        end
107 114
       end
108 115
     end
109 116
   end
110  
-end
  117
+end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.