bones-git 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/README.txt +39 -0
- data/Rakefile +25 -0
- data/lib/bones/app/git.rb +93 -0
- data/lib/bones/plugins/git.rb +80 -0
- metadata +94 -0
data/History.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
bones-git
|
2
|
+
by Tim Pease
|
3
|
+
http://gemcutter.org/gems/bones-git
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
The git package for Mr Bones provides tasks to incorporate git actions into
|
8
|
+
gem release. It also provides some extensions to the Mr Bones "create" command
|
9
|
+
that allow you to initialize a git repository and to create a new GitHub
|
10
|
+
project.
|
11
|
+
|
12
|
+
== INSTALL:
|
13
|
+
|
14
|
+
sudo gem install bones-git
|
15
|
+
|
16
|
+
== LICENSE:
|
17
|
+
|
18
|
+
(The MIT License)
|
19
|
+
|
20
|
+
Copyright (c) 2009
|
21
|
+
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
23
|
+
a copy of this software and associated documentation files (the
|
24
|
+
'Software'), to deal in the Software without restriction, including
|
25
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
26
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
27
|
+
permit persons to whom the Software is furnished to do so, subject to
|
28
|
+
the following conditions:
|
29
|
+
|
30
|
+
The above copyright notice and this permission notice shall be
|
31
|
+
included in all copies or substantial portions of the Software.
|
32
|
+
|
33
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
34
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
35
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
36
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
37
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
38
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
39
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
rescue LoadError
|
5
|
+
abort '### Please install the "bones" gem ###'
|
6
|
+
end
|
7
|
+
|
8
|
+
ensure_in_path 'lib'
|
9
|
+
|
10
|
+
Bones {
|
11
|
+
name 'bones-git'
|
12
|
+
authors 'Tim Pease'
|
13
|
+
email 'tim.pease@gmail.com'
|
14
|
+
url 'http://github.com/TwP/bones-git'
|
15
|
+
version '1.0.0'
|
16
|
+
ignore_file '.gitignore'
|
17
|
+
|
18
|
+
depend_on 'bones'
|
19
|
+
depend_on 'git'
|
20
|
+
|
21
|
+
use_gmail
|
22
|
+
enable_sudo
|
23
|
+
}
|
24
|
+
|
25
|
+
# EOF
|
@@ -0,0 +1,93 @@
|
|
1
|
+
|
2
|
+
require 'git'
|
3
|
+
|
4
|
+
module Bones::App::Git
|
5
|
+
|
6
|
+
def self.initialize_git
|
7
|
+
Bones::App::Create.class_eval {
|
8
|
+
include ::Bones::App::Git
|
9
|
+
|
10
|
+
option
|
11
|
+
option('Git Options:')
|
12
|
+
option('--git', 'Initialize a git repository for the project.',
|
13
|
+
lambda { config[:git] = true }
|
14
|
+
)
|
15
|
+
option('--github DESCRIPTION', 'Create a new GitHub project.',
|
16
|
+
'Requires a project description.',
|
17
|
+
lambda { |desc|
|
18
|
+
config[:git] = true,
|
19
|
+
config[:github] = true,
|
20
|
+
config[:github_desc] = desc
|
21
|
+
}
|
22
|
+
)
|
23
|
+
|
24
|
+
in_output_directory :initialize_git, :initialize_github
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize_git
|
29
|
+
return unless @config[:git]
|
30
|
+
|
31
|
+
File.rename('.bnsignore', '.gitignore') if test ?f, '.bnsignore'
|
32
|
+
|
33
|
+
author = Git.global_config['user.name']
|
34
|
+
email = Git.global_config['user.email']
|
35
|
+
|
36
|
+
if test ?f, 'Rakefile'
|
37
|
+
lines = File.readlines 'Rakefile'
|
38
|
+
|
39
|
+
lines.each do |line|
|
40
|
+
case line
|
41
|
+
when %r/^\s*authors\s+/
|
42
|
+
line.replace " authors '#{author}'" unless author.nil? or line !~ %r/FIXME/
|
43
|
+
when %r/^\s*email\s+/
|
44
|
+
line.replace " email '#{email}'" unless email.nil? or line !~ %r/FIXME/
|
45
|
+
when %r/^\s*url\s+/
|
46
|
+
next unless @config[:github]
|
47
|
+
url = github_url
|
48
|
+
line.replace " url '#{url}'" unless url.nil? or line !~ %r/FIXME/
|
49
|
+
when %r/^\s*\}\s*$/
|
50
|
+
line.insert 0, " ignore_file '.gitignore'\n" if test ?f, '.gitignore'
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
File.open('Rakefile', 'w') {|fd| fd.puts lines}
|
55
|
+
end
|
56
|
+
|
57
|
+
@git = Git.init
|
58
|
+
@git.add
|
59
|
+
@git.commit "Initial commit to #{name}."
|
60
|
+
end
|
61
|
+
|
62
|
+
def initialize_github
|
63
|
+
return unless @config[:github]
|
64
|
+
|
65
|
+
user = Git.global_config['github.user']
|
66
|
+
token = Git.global_config['github.token']
|
67
|
+
|
68
|
+
raise Error, 'A GitHub username was not found in the global configuration.' unless user
|
69
|
+
raise Error, 'A GitHub token was not found in the global configuration.' unless token
|
70
|
+
|
71
|
+
Net::HTTP.post_form(
|
72
|
+
URI.parse('http://github.com/api/v2/yaml/repos/create'),
|
73
|
+
'login' => user,
|
74
|
+
'token' => token,
|
75
|
+
'name' => name,
|
76
|
+
'description' => @config[:github_desc]
|
77
|
+
)
|
78
|
+
|
79
|
+
@git.add_remote 'origin', "git@github.com:#{user}/#{name}.git"
|
80
|
+
@git.config 'branch.master.remote', 'origin'
|
81
|
+
@git.config 'branch.master.merge', 'refs/heads/master'
|
82
|
+
@git.push 'origin'
|
83
|
+
end
|
84
|
+
|
85
|
+
def github_url
|
86
|
+
user = Git.global_config['github.user']
|
87
|
+
return unless user
|
88
|
+
"http://github.com/#{user}/#{name}"
|
89
|
+
end
|
90
|
+
|
91
|
+
end # module Bones::App::Git
|
92
|
+
|
93
|
+
# EOF
|
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
require 'git'
|
3
|
+
|
4
|
+
module Bones::Plugins::Git
|
5
|
+
include ::Bones::Helpers
|
6
|
+
extend self
|
7
|
+
|
8
|
+
def post_load
|
9
|
+
have?(:git) {
|
10
|
+
Dir.entries(Dir.pwd).include?('.git') and
|
11
|
+
system("git --version 2>&1 > #{DEV_NULL}")
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def define_tasks
|
16
|
+
return unless have? :git
|
17
|
+
|
18
|
+
config = ::Bones.config
|
19
|
+
namespace :git do
|
20
|
+
|
21
|
+
# A prerequisites task that all other tasks depend upon
|
22
|
+
task :prereqs
|
23
|
+
|
24
|
+
desc 'Show tags from the git repository'
|
25
|
+
task :tags => 'git:prereqs' do |t|
|
26
|
+
puts Git.open('.').tags.map {|t| t.name}.reverse
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Create a new tag in the git repository'
|
30
|
+
task :create_tag => 'git:prereqs' do |t|
|
31
|
+
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
32
|
+
abort "Versions don't match #{v} vs #{config.version}" if v != config.version
|
33
|
+
|
34
|
+
git = Git.open '.'
|
35
|
+
tag = "%s-%s" % [config.name, config.version]
|
36
|
+
puts "Creating git tag '#{tag}'."
|
37
|
+
|
38
|
+
begin
|
39
|
+
git.add_tag tag
|
40
|
+
rescue Git::GitExecuteError
|
41
|
+
abort "Tag creation failed: tag '#{tag}' already exists."
|
42
|
+
end
|
43
|
+
|
44
|
+
if git.remotes.map {|r| r.name}.include? 'origin'
|
45
|
+
unless system "git push origin #{tag}"
|
46
|
+
abort "Could not push tag to remote git repository."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end # task
|
50
|
+
|
51
|
+
desc 'Delete a tag from the git repository'
|
52
|
+
task :delete_tag => 'git:prereqs' do |t|
|
53
|
+
v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
|
54
|
+
|
55
|
+
git = Git.open '.'
|
56
|
+
tag = "%s-%s" % [config.name, v]
|
57
|
+
|
58
|
+
unless git.tags.map {|t| t.name}.include? tag
|
59
|
+
puts "Tag '#{tag}' does not exist."
|
60
|
+
break
|
61
|
+
end
|
62
|
+
|
63
|
+
puts "Deleting git tag '#{tag}'."
|
64
|
+
abort 'Tag deletion failed.' unless system "git tag -d '#{tag}'"
|
65
|
+
|
66
|
+
if git.remotes.map {|r| r.name}.include? 'origin'
|
67
|
+
unless system "git push origin ':refs/tags/#{tag}'"
|
68
|
+
abort "Could not delete tag from remote git repository."
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end # task
|
72
|
+
|
73
|
+
end # namespace :git
|
74
|
+
|
75
|
+
task 'gem:release' => 'git:create_tag'
|
76
|
+
end
|
77
|
+
|
78
|
+
end # module Bones::Plugins::Git
|
79
|
+
|
80
|
+
# EOF
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bones-git
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Pease
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-07 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bones
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.0.0
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: git
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.5
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: bones
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.0.0
|
44
|
+
version:
|
45
|
+
description: |-
|
46
|
+
The git package for Mr Bones provides tasks to incorporate git actions into
|
47
|
+
gem release. It also provides some extensions to the Mr Bones "create" command
|
48
|
+
that allow you to initialize a git repository and to create a new GitHub
|
49
|
+
project.
|
50
|
+
email: tim.pease@gmail.com
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- History.txt
|
57
|
+
- README.txt
|
58
|
+
files:
|
59
|
+
- History.txt
|
60
|
+
- README.txt
|
61
|
+
- Rakefile
|
62
|
+
- lib/bones/app/git.rb
|
63
|
+
- lib/bones/plugins/git.rb
|
64
|
+
has_rdoc: true
|
65
|
+
homepage: http://github.com/TwP/bones-git
|
66
|
+
licenses: []
|
67
|
+
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options:
|
70
|
+
- --main
|
71
|
+
- README.txt
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
79
|
+
version:
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
requirements: []
|
87
|
+
|
88
|
+
rubyforge_project: bones-git
|
89
|
+
rubygems_version: 1.3.5
|
90
|
+
signing_key:
|
91
|
+
specification_version: 3
|
92
|
+
summary: The git package for Mr Bones provides tasks to incorporate git actions into gem release
|
93
|
+
test_files: []
|
94
|
+
|