vagrant-plugin-dummy 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +20 -0
- data/Gemfile +11 -0
- data/README.md +24 -0
- data/Rakefile +15 -0
- data/lib/vagrant-plugin-dummy/communication/communicator.rb +51 -0
- data/lib/vagrant-plugin-dummy/errors.rb +13 -0
- data/lib/vagrant-plugin-dummy/guest/dummy.rb +48 -0
- data/lib/vagrant-plugin-dummy/monkey_patches/lib/vagrant/machine.rb +27 -0
- data/lib/vagrant-plugin-dummy/plugin.rb +100 -0
- data/lib/vagrant-plugin-dummy/version.rb +3 -0
- data/lib/vagrant-plugin-dummy.rb +24 -0
- data/locales/en.yml +8 -0
- data/oldgit/FETCH_HEAD +4 -0
- data/oldgit/HEAD +1 -0
- data/oldgit/ORIG_HEAD +1 -0
- data/oldgit/config +12 -0
- data/oldgit/description +1 -0
- data/oldgit/hooks/applypatch-msg.sample +15 -0
- data/oldgit/hooks/commit-msg.sample +24 -0
- data/oldgit/hooks/post-update.sample +8 -0
- data/oldgit/hooks/pre-applypatch.sample +14 -0
- data/oldgit/hooks/pre-commit.sample +50 -0
- data/oldgit/hooks/pre-rebase.sample +169 -0
- data/oldgit/hooks/prepare-commit-msg.sample +36 -0
- data/oldgit/hooks/update.sample +128 -0
- data/oldgit/index +0 -0
- data/oldgit/info/exclude +6 -0
- data/oldgit/logs/HEAD +13 -0
- data/oldgit/logs/refs/heads/dummy-master +1 -0
- data/oldgit/logs/refs/heads/master +2 -0
- data/oldgit/logs/refs/heads/vagrant-1.2 +3 -0
- data/oldgit/logs/refs/remotes/origin/HEAD +1 -0
- data/oldgit/logs/refs/remotes/origin/chef-schtasks +1 -0
- data/oldgit/logs/refs/remotes/origin/master +2 -0
- data/oldgit/logs/refs/remotes/origin/vagrant-1.2 +3 -0
- data/oldgit/logs/refs/remotes/origin/winrm-2.0 +1 -0
- data/oldgit/objects/pack/pack-829e113048479ca488917c38a7779511189ee623.idx +0 -0
- data/oldgit/objects/pack/pack-829e113048479ca488917c38a7779511189ee623.pack +0 -0
- data/oldgit/objects/pack/pack-9d783f03b5d312d0eb7c60c232336524cf240841.idx +0 -0
- data/oldgit/objects/pack/pack-9d783f03b5d312d0eb7c60c232336524cf240841.pack +0 -0
- data/oldgit/objects/pack/pack-fc30e147a30fce4b4b0e300c3cdb4743945456d4.idx +0 -0
- data/oldgit/objects/pack/pack-fc30e147a30fce4b4b0e300c3cdb4743945456d4.pack +0 -0
- data/oldgit/packed-refs +9 -0
- data/oldgit/refs/heads/dummy-master +1 -0
- data/oldgit/refs/heads/master +1 -0
- data/oldgit/refs/heads/vagrant-1.2 +1 -0
- data/oldgit/refs/remotes/origin/chef-schtasks +1 -0
- data/oldgit/refs/remotes/origin/master +1 -0
- data/oldgit/refs/remotes/origin/vagrant-1.2 +1 -0
- data/oldgit/refs/remotes/origin/winrm-2.0 +1 -0
- data/spec/vagrant-windows/config_spec.rb +58 -0
- data/spec/vagrant-windows/guestnetwork_spec.rb +48 -0
- data/spec/vagrant-windows/helper_spec.rb +38 -0
- data/spec/vagrant-windows/winrmcommunicator_spec.rb +27 -0
- data/vagrant-plugin-dummy.gemspec +53 -0
- data/windows/communication/guestnetwork.rb +133 -0
- data/windows/communication/winrmcommunicator.rb +120 -0
- data/windows/communication/winrmfinder.rb +45 -0
- data/windows/communication/winrmshell.rb +141 -0
- data/windows/config/windows.rb +35 -0
- data/windows/config/winrm.rb +51 -0
- data/windows/errors.rb +27 -0
- data/windows/guest/cap/change_host_name.rb +14 -0
- data/windows/guest/cap/configure_networks.rb +69 -0
- data/windows/guest/cap/halt.rb +22 -0
- data/windows/guest/cap/mount_virtualbox_shared_folder.rb +17 -0
- data/windows/guest/cap/mount_vmware_shared_folder.rb +15 -0
- data/windows/guest/windows.rb +71 -0
- data/windows/helper.rb +19 -0
- data/windows/monkey_patches/lib/vagrant/machine.rb +32 -0
- data/windows/monkey_patches/plugins/providers/virtualbox/action/share_folders.rb +44 -0
- data/windows/monkey_patches/plugins/providers/virtualbox/driver/version_4_2.rb +20 -0
- data/windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_client.rb +1 -0
- data/windows/monkey_patches/plugins/provisioners/chef/provisioner/chef_solo.rb +106 -0
- data/windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet.rb +101 -0
- data/windows/monkey_patches/plugins/provisioners/puppet/provisioner/puppet_server.rb +1 -0
- data/windows/monkey_patches/plugins/provisioners/shell/provisioner.rb +89 -0
- data/windows/plugin.rb +129 -0
- data/windows/scripts/cheftask.ps1.erb +47 -0
- data/windows/scripts/cheftask.xml.erb +45 -0
- data/windows/scripts/cheftaskrun.ps1.erb +16 -0
- data/windows/scripts/command_alias.ps1 +36 -0
- data/windows/scripts/mount_volume.virtualbox.ps1.erb +49 -0
- data/windows/scripts/mount_volume.vmware.ps1.erb +49 -0
- data/windows/scripts/set_work_network.ps1 +6 -0
- data/windows/scripts/winrs_v3_get_adapters.ps1 +11 -0
- data/windows/version.rb +3 -0
- metadata +207 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in my_gem.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
# We depend on Vagrant for development, but we don't add it as a
|
8
|
+
# gem dependency because we expect to be installed within the
|
9
|
+
# Vagrant environment itself using `vagrant plugin`.
|
10
|
+
gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git", :tag => 'v1.2.7'
|
11
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
vagrant-plugin-dummy
|
2
|
+
==========================
|
3
|
+
|
4
|
+
This is a "dummy" plugin for vagrant. This is useful if you want to only use vagrant for creating and destroying clean guests.
|
5
|
+
|
6
|
+
Installing vagrant-plugin-dummy
|
7
|
+
==========================
|
8
|
+
|
9
|
+
### Installing from source
|
10
|
+
|
11
|
+
```
|
12
|
+
bundle install
|
13
|
+
bundle exec rake
|
14
|
+
vagrant plugin install pkg/vagrant-plugin-dummy-0.0.1.gem
|
15
|
+
```
|
16
|
+
|
17
|
+
Usage
|
18
|
+
==========================
|
19
|
+
|
20
|
+
Addd this to a Vagrantfile:
|
21
|
+
|
22
|
+
```
|
23
|
+
config.vm.guest :dummy
|
24
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
# Change to the directory of this file.
|
6
|
+
Dir.chdir(File.expand_path("../", __FILE__))
|
7
|
+
|
8
|
+
# For gem creation and bundling
|
9
|
+
require "bundler/gem_tasks"
|
10
|
+
|
11
|
+
# Install the `spec` task so that we can run tests.
|
12
|
+
RSpec::Core::RakeTask.new
|
13
|
+
|
14
|
+
# Default task is to build the gem
|
15
|
+
task :default => "build"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
require 'log4r'
|
3
|
+
require_relative '../errors'
|
4
|
+
|
5
|
+
module VagrantPluginDummy
|
6
|
+
module Communication
|
7
|
+
# Provides no communication with the machine.
|
8
|
+
class DummyCommunicator < Vagrant.plugin("2", :communicator)
|
9
|
+
|
10
|
+
attr_reader :logger
|
11
|
+
attr_reader :machine
|
12
|
+
|
13
|
+
def self.match?(machine)
|
14
|
+
machine.config.vm.guest.eql? :dummy
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(machine)
|
18
|
+
@machine = machine
|
19
|
+
@logger = Log4r::Logger.new("vagrant_plugin_dummy::communication::dummycommunicator")
|
20
|
+
@logger.debug("initializing DummyCommunicator")
|
21
|
+
end
|
22
|
+
|
23
|
+
def ready?
|
24
|
+
@logger.warn("Assuming the machine is ready.")
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute(command, opts={}, &block)
|
29
|
+
@logger.warn("DummyCommunicator.execute isn't implemented")
|
30
|
+
return 0
|
31
|
+
end
|
32
|
+
alias_method :sudo, :execute
|
33
|
+
|
34
|
+
def test(command, opts=nil)
|
35
|
+
return false unless @machine.config.vm.guest.eql? :dummy
|
36
|
+
end
|
37
|
+
|
38
|
+
def upload(from, to)
|
39
|
+
@logger.warn("DummyCommunicator.upload isn't implemented")
|
40
|
+
end
|
41
|
+
|
42
|
+
def download(from, to=nil)
|
43
|
+
@logger.warn("DummyCommunicator.download isn't implemented")
|
44
|
+
end
|
45
|
+
|
46
|
+
def session
|
47
|
+
@session ||= new_session
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'vagrant/errors'
|
2
|
+
|
3
|
+
module VagrantPluginDummy
|
4
|
+
module Errors
|
5
|
+
class VagrantPluginDummyError < ::Vagrant::Errors::VagrantError
|
6
|
+
error_namespace("vagrant_plugin_dummy.errors")
|
7
|
+
end
|
8
|
+
|
9
|
+
class PluginDummyError < VagrantPluginDummyError
|
10
|
+
error_key(:plugin_dummy_error)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "vagrant"
|
2
|
+
|
3
|
+
module VagrantPluginDummy
|
4
|
+
module Guest
|
5
|
+
class Dummy < Vagrant.plugin("2", :guest)
|
6
|
+
|
7
|
+
# Vagrant 1.1.x compatibibility methods
|
8
|
+
# Implement the 1.1.x methods and call through to the new 1.2.x capabilities
|
9
|
+
|
10
|
+
attr_reader :machine
|
11
|
+
|
12
|
+
def initialize(machine = nil)
|
13
|
+
super(machine) unless machine == nil
|
14
|
+
@machine = machine
|
15
|
+
end
|
16
|
+
|
17
|
+
def change_host_name(name)
|
18
|
+
false
|
19
|
+
end
|
20
|
+
|
21
|
+
def distro_dispatch
|
22
|
+
:dummy
|
23
|
+
end
|
24
|
+
|
25
|
+
def halt
|
26
|
+
false
|
27
|
+
end
|
28
|
+
|
29
|
+
def mount_virtualbox_shared_folder(name, guestpath, options)
|
30
|
+
false
|
31
|
+
end
|
32
|
+
|
33
|
+
def mount_vmware_shared_folder(name, guestpath, options)
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def configure_networks(networks)
|
38
|
+
false
|
39
|
+
end
|
40
|
+
|
41
|
+
# Vagrant 1.2.x compatibibility methods
|
42
|
+
|
43
|
+
def detect?(machine)
|
44
|
+
@machine.communicate.test("")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative '../../../communication/communicator'
|
2
|
+
|
3
|
+
module Vagrant
|
4
|
+
class Machine
|
5
|
+
|
6
|
+
ssh_communicate = instance_method(:communicate)
|
7
|
+
|
8
|
+
# This patch is needed until Vagrant supports a configurable communication channel
|
9
|
+
define_method(:communicate) do
|
10
|
+
unless @communicator
|
11
|
+
if @config.vm.guest.eql? :dummy
|
12
|
+
@logger.info("guest is #{@config.vm.guest}, using no communication channel")
|
13
|
+
@communicator = ::VagrantPluginDummy::Communication::DummyCommunicator.new(self)
|
14
|
+
else
|
15
|
+
@logger.info("guest is #{@config.vm.guest}, using SSH for communication channel")
|
16
|
+
@communicator = ssh_communicate.bind(self).()
|
17
|
+
end
|
18
|
+
end
|
19
|
+
@communicator
|
20
|
+
end
|
21
|
+
|
22
|
+
def is_dummy?
|
23
|
+
return @config.vm.guest.eql? :dummy
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
begin
|
2
|
+
require "vagrant"
|
3
|
+
rescue LoadError
|
4
|
+
raise "The vagrant-plugin-dummy vagrant plugin must be run with vagrant."
|
5
|
+
end
|
6
|
+
|
7
|
+
# This is a sanity check to make sure no one is attempting to install
|
8
|
+
# this into an early Vagrant version.
|
9
|
+
if Vagrant::VERSION < "1.1.0"
|
10
|
+
raise "The vagrant-plugin-dummy vagrant plugin is only compatible with Vagrant 1.1+"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Monkey Patch the VM object to support a non-existing communication channel
|
14
|
+
# TODO: is this necessary?
|
15
|
+
require_relative "monkey_patches/lib/vagrant/machine"
|
16
|
+
|
17
|
+
module VagrantPluginDummy
|
18
|
+
class Plugin < Vagrant.plugin("2")
|
19
|
+
name "Dummy guest"
|
20
|
+
description <<-DESC
|
21
|
+
This plugin installs a provider that tries its best to not touch the
|
22
|
+
machine.
|
23
|
+
DESC
|
24
|
+
|
25
|
+
guest(:dummy) do
|
26
|
+
require_relative "guest/dummy"
|
27
|
+
VagrantPluginDummy::Guest::Dummy
|
28
|
+
end
|
29
|
+
|
30
|
+
# Vagrant 1.2 introduced the concept of capabilities instead of implementing
|
31
|
+
# an interface on the guest.
|
32
|
+
# if Vagrant::VERSION >= "1.2.0"
|
33
|
+
#
|
34
|
+
# guest_capability(:windows, :change_host_name) do
|
35
|
+
# require_relative "guest/cap/change_host_name"
|
36
|
+
# VagrantPluginDummy::Guest::Cap::ChangeHostName
|
37
|
+
# end
|
38
|
+
#
|
39
|
+
# guest_capability(:windows, :configure_networks) do
|
40
|
+
# require_relative "guest/cap/configure_networks"
|
41
|
+
# VagrantPluginDummy::Guest::Cap::ConfigureNetworks
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# guest_capability(:windows, :halt) do
|
45
|
+
# require_relative "guest/cap/halt"
|
46
|
+
# VagrantPluginDummy::Guest::Cap::Halt
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# guest_capability(:windows, :mount_virtualbox_shared_folder) do
|
50
|
+
# require_relative "guest/cap/mount_virtualbox_shared_folder"
|
51
|
+
# VagrantPluginDummy::Guest::Cap::MountVirtualBoxSharedFolder
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# guest_capability(:windows, :mount_vmware_shared_folder) do
|
55
|
+
# require_relative "guest/cap/mount_vmware_shared_folder"
|
56
|
+
# VagrantPluginDummy::Guest::Cap::MountVMwareSharedFolder
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# end
|
60
|
+
|
61
|
+
# This initializes the internationalization strings.
|
62
|
+
def self.setup_i18n
|
63
|
+
I18n.load_path << File.expand_path("locales/en.yml", VagrantPluginDummy.vagrant_plugin_dummy_root)
|
64
|
+
I18n.reload!
|
65
|
+
end
|
66
|
+
|
67
|
+
# This sets up our log level to be whatever VAGRANT_LOG is.
|
68
|
+
def self.setup_logging
|
69
|
+
require "log4r"
|
70
|
+
|
71
|
+
level = nil
|
72
|
+
begin
|
73
|
+
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
74
|
+
rescue NameError
|
75
|
+
# This means that the logging constant wasn't found,
|
76
|
+
# which is fine. We just keep `level` as `nil`. But
|
77
|
+
# we tell the user.
|
78
|
+
level = nil
|
79
|
+
end
|
80
|
+
|
81
|
+
# Some constants, such as "true" resolve to booleans, so the
|
82
|
+
# above error checking doesn't catch it. This will check to make
|
83
|
+
# sure that the log level is an integer, as Log4r requires.
|
84
|
+
level = nil if !level.is_a?(Integer)
|
85
|
+
|
86
|
+
# Set the logging level on all "vagrant" namespaced
|
87
|
+
# logs as long as we have a valid level.
|
88
|
+
if level
|
89
|
+
logger = Log4r::Logger.new("vagrant_plugin_dummy")
|
90
|
+
logger.outputters = Log4r::Outputter.stderr
|
91
|
+
logger.level = level
|
92
|
+
logger = nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
VagrantPluginDummy::Plugin.setup_logging()
|
100
|
+
VagrantPluginDummy::Plugin.setup_i18n()
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
module VagrantPluginDummy
|
4
|
+
|
5
|
+
def self.vagrant_plugin_dummy_root
|
6
|
+
@vagrant_plugin_dummy_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.load_script(script_file_name)
|
10
|
+
File.read(expand_script_path(script_file_name))
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.load_script_template(script_file_name, options)
|
14
|
+
Vagrant::Util::TemplateRenderer.render(expand_script_path(script_file_name), options)
|
15
|
+
end
|
16
|
+
|
17
|
+
# TODO: unnecessary?
|
18
|
+
def self.expand_script_path(script_file_name)
|
19
|
+
File.expand_path("lib/vagrant-plugin-dummy/scripts/#{script_file_name}", VagrantPluginDummy.vagrant_plugin_dummy_root)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
require "vagrant-plugin-dummy/plugin"
|
data/locales/en.yml
ADDED
data/oldgit/FETCH_HEAD
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
10332b013b911516b20c344f933aadafefc9b752 not-for-merge branch 'chef-schtasks' of github.com:WinRb/vagrant-windows
|
2
|
+
a98d27d5b4f16de29bd3bf9c486d25b14d5960c3 not-for-merge branch 'master' of github.com:WinRb/vagrant-windows
|
3
|
+
b4c93197e40d3c2b38d06f316bfb1fd5f0a120de not-for-merge branch 'vagrant-1.2' of github.com:WinRb/vagrant-windows
|
4
|
+
f09f1b803ab437ec9e31d28560df03add6944308 not-for-merge branch 'winrm-2.0' of github.com:WinRb/vagrant-windows
|
data/oldgit/HEAD
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ref: refs/heads/dummy-master
|
data/oldgit/ORIG_HEAD
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
b4c93197e40d3c2b38d06f316bfb1fd5f0a120de
|
data/oldgit/config
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
[core]
|
2
|
+
repositoryformatversion = 0
|
3
|
+
filemode = true
|
4
|
+
bare = false
|
5
|
+
logallrefupdates = true
|
6
|
+
[branch "master"]
|
7
|
+
[remote "origin"]
|
8
|
+
url = git@github.com:WinRb/vagrant-windows.git
|
9
|
+
fetch = +refs/heads/*:refs/remotes/origin/*
|
10
|
+
[branch "vagrant-1.2"]
|
11
|
+
remote = origin
|
12
|
+
merge = refs/heads/vagrant-1.2
|
data/oldgit/description
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Unnamed repository; edit this file 'description' to name the repository.
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to check the commit log message taken by
|
4
|
+
# applypatch from an e-mail message.
|
5
|
+
#
|
6
|
+
# The hook should exit with non-zero status after issuing an
|
7
|
+
# appropriate message if it wants to stop the commit. The hook is
|
8
|
+
# allowed to edit the commit message file.
|
9
|
+
#
|
10
|
+
# To enable this hook, rename this file to "applypatch-msg".
|
11
|
+
|
12
|
+
. git-sh-setup
|
13
|
+
test -x "$GIT_DIR/hooks/commit-msg" &&
|
14
|
+
exec "$GIT_DIR/hooks/commit-msg" ${1+"$@"}
|
15
|
+
:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to check the commit log message.
|
4
|
+
# Called by "git commit" with one argument, the name of the file
|
5
|
+
# that has the commit message. The hook should exit with non-zero
|
6
|
+
# status after issuing an appropriate message if it wants to stop the
|
7
|
+
# commit. The hook is allowed to edit the commit message file.
|
8
|
+
#
|
9
|
+
# To enable this hook, rename this file to "commit-msg".
|
10
|
+
|
11
|
+
# Uncomment the below to add a Signed-off-by line to the message.
|
12
|
+
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
|
13
|
+
# hook is more suited to it.
|
14
|
+
#
|
15
|
+
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
16
|
+
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
|
17
|
+
|
18
|
+
# This example catches duplicate Signed-off-by lines.
|
19
|
+
|
20
|
+
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
21
|
+
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
22
|
+
echo >&2 Duplicate Signed-off-by lines.
|
23
|
+
exit 1
|
24
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to verify what is about to be committed
|
4
|
+
# by applypatch from an e-mail message.
|
5
|
+
#
|
6
|
+
# The hook should exit with non-zero status after issuing an
|
7
|
+
# appropriate message if it wants to stop the commit.
|
8
|
+
#
|
9
|
+
# To enable this hook, rename this file to "pre-applypatch".
|
10
|
+
|
11
|
+
. git-sh-setup
|
12
|
+
test -x "$GIT_DIR/hooks/pre-commit" &&
|
13
|
+
exec "$GIT_DIR/hooks/pre-commit" ${1+"$@"}
|
14
|
+
:
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# An example hook script to verify what is about to be committed.
|
4
|
+
# Called by "git commit" with no arguments. The hook should
|
5
|
+
# exit with non-zero status after issuing an appropriate message if
|
6
|
+
# it wants to stop the commit.
|
7
|
+
#
|
8
|
+
# To enable this hook, rename this file to "pre-commit".
|
9
|
+
|
10
|
+
if git rev-parse --verify HEAD >/dev/null 2>&1
|
11
|
+
then
|
12
|
+
against=HEAD
|
13
|
+
else
|
14
|
+
# Initial commit: diff against an empty tree object
|
15
|
+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
16
|
+
fi
|
17
|
+
|
18
|
+
# If you want to allow non-ascii filenames set this variable to true.
|
19
|
+
allownonascii=$(git config hooks.allownonascii)
|
20
|
+
|
21
|
+
# Redirect output to stderr.
|
22
|
+
exec 1>&2
|
23
|
+
|
24
|
+
# Cross platform projects tend to avoid non-ascii filenames; prevent
|
25
|
+
# them from being added to the repository. We exploit the fact that the
|
26
|
+
# printable range starts at the space character and ends with tilde.
|
27
|
+
if [ "$allownonascii" != "true" ] &&
|
28
|
+
# Note that the use of brackets around a tr range is ok here, (it's
|
29
|
+
# even required, for portability to Solaris 10's /usr/bin/tr), since
|
30
|
+
# the square bracket bytes happen to fall in the designated range.
|
31
|
+
test $(git diff --cached --name-only --diff-filter=A -z $against |
|
32
|
+
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
|
33
|
+
then
|
34
|
+
echo "Error: Attempt to add a non-ascii file name."
|
35
|
+
echo
|
36
|
+
echo "This can cause problems if you want to work"
|
37
|
+
echo "with people on other platforms."
|
38
|
+
echo
|
39
|
+
echo "To be portable it is advisable to rename the file ..."
|
40
|
+
echo
|
41
|
+
echo "If you know what you are doing you can disable this"
|
42
|
+
echo "check using:"
|
43
|
+
echo
|
44
|
+
echo " git config hooks.allownonascii true"
|
45
|
+
echo
|
46
|
+
exit 1
|
47
|
+
fi
|
48
|
+
|
49
|
+
# If there are whitespace errors, print the offending file names and fail.
|
50
|
+
exec git diff-index --check --cached $against --
|
@@ -0,0 +1,169 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
#
|
3
|
+
# Copyright (c) 2006, 2008 Junio C Hamano
|
4
|
+
#
|
5
|
+
# The "pre-rebase" hook is run just before "git rebase" starts doing
|
6
|
+
# its job, and can prevent the command from running by exiting with
|
7
|
+
# non-zero status.
|
8
|
+
#
|
9
|
+
# The hook is called with the following parameters:
|
10
|
+
#
|
11
|
+
# $1 -- the upstream the series was forked from.
|
12
|
+
# $2 -- the branch being rebased (or empty when rebasing the current branch).
|
13
|
+
#
|
14
|
+
# This sample shows how to prevent topic branches that are already
|
15
|
+
# merged to 'next' branch from getting rebased, because allowing it
|
16
|
+
# would result in rebasing already published history.
|
17
|
+
|
18
|
+
publish=next
|
19
|
+
basebranch="$1"
|
20
|
+
if test "$#" = 2
|
21
|
+
then
|
22
|
+
topic="refs/heads/$2"
|
23
|
+
else
|
24
|
+
topic=`git symbolic-ref HEAD` ||
|
25
|
+
exit 0 ;# we do not interrupt rebasing detached HEAD
|
26
|
+
fi
|
27
|
+
|
28
|
+
case "$topic" in
|
29
|
+
refs/heads/??/*)
|
30
|
+
;;
|
31
|
+
*)
|
32
|
+
exit 0 ;# we do not interrupt others.
|
33
|
+
;;
|
34
|
+
esac
|
35
|
+
|
36
|
+
# Now we are dealing with a topic branch being rebased
|
37
|
+
# on top of master. Is it OK to rebase it?
|
38
|
+
|
39
|
+
# Does the topic really exist?
|
40
|
+
git show-ref -q "$topic" || {
|
41
|
+
echo >&2 "No such branch $topic"
|
42
|
+
exit 1
|
43
|
+
}
|
44
|
+
|
45
|
+
# Is topic fully merged to master?
|
46
|
+
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
|
47
|
+
if test -z "$not_in_master"
|
48
|
+
then
|
49
|
+
echo >&2 "$topic is fully merged to master; better remove it."
|
50
|
+
exit 1 ;# we could allow it, but there is no point.
|
51
|
+
fi
|
52
|
+
|
53
|
+
# Is topic ever merged to next? If so you should not be rebasing it.
|
54
|
+
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
|
55
|
+
only_next_2=`git rev-list ^master ${publish} | sort`
|
56
|
+
if test "$only_next_1" = "$only_next_2"
|
57
|
+
then
|
58
|
+
not_in_topic=`git rev-list "^$topic" master`
|
59
|
+
if test -z "$not_in_topic"
|
60
|
+
then
|
61
|
+
echo >&2 "$topic is already up-to-date with master"
|
62
|
+
exit 1 ;# we could allow it, but there is no point.
|
63
|
+
else
|
64
|
+
exit 0
|
65
|
+
fi
|
66
|
+
else
|
67
|
+
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
|
68
|
+
/usr/bin/perl -e '
|
69
|
+
my $topic = $ARGV[0];
|
70
|
+
my $msg = "* $topic has commits already merged to public branch:\n";
|
71
|
+
my (%not_in_next) = map {
|
72
|
+
/^([0-9a-f]+) /;
|
73
|
+
($1 => 1);
|
74
|
+
} split(/\n/, $ARGV[1]);
|
75
|
+
for my $elem (map {
|
76
|
+
/^([0-9a-f]+) (.*)$/;
|
77
|
+
[$1 => $2];
|
78
|
+
} split(/\n/, $ARGV[2])) {
|
79
|
+
if (!exists $not_in_next{$elem->[0]}) {
|
80
|
+
if ($msg) {
|
81
|
+
print STDERR $msg;
|
82
|
+
undef $msg;
|
83
|
+
}
|
84
|
+
print STDERR " $elem->[1]\n";
|
85
|
+
}
|
86
|
+
}
|
87
|
+
' "$topic" "$not_in_next" "$not_in_master"
|
88
|
+
exit 1
|
89
|
+
fi
|
90
|
+
|
91
|
+
<<\DOC_END
|
92
|
+
|
93
|
+
This sample hook safeguards topic branches that have been
|
94
|
+
published from being rewound.
|
95
|
+
|
96
|
+
The workflow assumed here is:
|
97
|
+
|
98
|
+
* Once a topic branch forks from "master", "master" is never
|
99
|
+
merged into it again (either directly or indirectly).
|
100
|
+
|
101
|
+
* Once a topic branch is fully cooked and merged into "master",
|
102
|
+
it is deleted. If you need to build on top of it to correct
|
103
|
+
earlier mistakes, a new topic branch is created by forking at
|
104
|
+
the tip of the "master". This is not strictly necessary, but
|
105
|
+
it makes it easier to keep your history simple.
|
106
|
+
|
107
|
+
* Whenever you need to test or publish your changes to topic
|
108
|
+
branches, merge them into "next" branch.
|
109
|
+
|
110
|
+
The script, being an example, hardcodes the publish branch name
|
111
|
+
to be "next", but it is trivial to make it configurable via
|
112
|
+
$GIT_DIR/config mechanism.
|
113
|
+
|
114
|
+
With this workflow, you would want to know:
|
115
|
+
|
116
|
+
(1) ... if a topic branch has ever been merged to "next". Young
|
117
|
+
topic branches can have stupid mistakes you would rather
|
118
|
+
clean up before publishing, and things that have not been
|
119
|
+
merged into other branches can be easily rebased without
|
120
|
+
affecting other people. But once it is published, you would
|
121
|
+
not want to rewind it.
|
122
|
+
|
123
|
+
(2) ... if a topic branch has been fully merged to "master".
|
124
|
+
Then you can delete it. More importantly, you should not
|
125
|
+
build on top of it -- other people may already want to
|
126
|
+
change things related to the topic as patches against your
|
127
|
+
"master", so if you need further changes, it is better to
|
128
|
+
fork the topic (perhaps with the same name) afresh from the
|
129
|
+
tip of "master".
|
130
|
+
|
131
|
+
Let's look at this example:
|
132
|
+
|
133
|
+
o---o---o---o---o---o---o---o---o---o "next"
|
134
|
+
/ / / /
|
135
|
+
/ a---a---b A / /
|
136
|
+
/ / / /
|
137
|
+
/ / c---c---c---c B /
|
138
|
+
/ / / \ /
|
139
|
+
/ / / b---b C \ /
|
140
|
+
/ / / / \ /
|
141
|
+
---o---o---o---o---o---o---o---o---o---o---o "master"
|
142
|
+
|
143
|
+
|
144
|
+
A, B and C are topic branches.
|
145
|
+
|
146
|
+
* A has one fix since it was merged up to "next".
|
147
|
+
|
148
|
+
* B has finished. It has been fully merged up to "master" and "next",
|
149
|
+
and is ready to be deleted.
|
150
|
+
|
151
|
+
* C has not merged to "next" at all.
|
152
|
+
|
153
|
+
We would want to allow C to be rebased, refuse A, and encourage
|
154
|
+
B to be deleted.
|
155
|
+
|
156
|
+
To compute (1):
|
157
|
+
|
158
|
+
git rev-list ^master ^topic next
|
159
|
+
git rev-list ^master next
|
160
|
+
|
161
|
+
if these match, topic has not merged in next at all.
|
162
|
+
|
163
|
+
To compute (2):
|
164
|
+
|
165
|
+
git rev-list master..topic
|
166
|
+
|
167
|
+
if this is empty, it is fully merged to "master".
|
168
|
+
|
169
|
+
DOC_END
|