Commit 28d13c35c9f361c633e4dd0bf45b92db0b867cad
1 parent
765f58f412
Add script/boxen-git-credential
boxen/puppet-git will need to be taught about this file.
Showing 1 changed file with 33 additions and 0 deletions Side-by-side Diff
script/boxen-git-credential
1 | +#!/usr/bin/ruby | |
2 | +# Provide git credentials using Boxen's config. | |
3 | + | |
4 | +unless command = ARGV.shift | |
5 | + this = File.basename $0 | |
6 | + abort "Usage: #{this} <get|store|erase>" | |
7 | +end | |
8 | + | |
9 | +# We only support get. | |
10 | + | |
11 | +exit 0 unless command == "get" | |
12 | + | |
13 | +# Make sure we're looking for github.com stuff. | |
14 | + | |
15 | +attrs = Hash[$stdin.read.split($/).map { |l| l.split("=") }] | |
16 | +exit 1 unless attrs["host"] == "github.com" | |
17 | + | |
18 | +require "pathname" | |
19 | + | |
20 | +# Put us where we belong, in the root dir of our boxen repo. | |
21 | + | |
22 | +Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |
23 | + | |
24 | +# Set up our local configuration, deps, and load path. | |
25 | + | |
26 | +load "config/basic.rb" | |
27 | + | |
28 | +require "boxen/config" | |
29 | + | |
30 | +config = Boxen::Config.load | |
31 | + | |
32 | +puts "username=#{config.login}" | |
33 | +puts "password=#{config.password}" |