slyphon-git-utils 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source(ENV['GEM_SOURCE'] || "http://rubygems.org")
2
+
3
+ # Specify your gem's dependencies in git-utils.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,72 @@
1
+ A small collection of git command-line subcommands implemented in ruby and
2
+ intended to be distributed using rubygems.
3
+
4
+ Currently, the only command in this collection is 'git cleanroom', which clones
5
+ the current repository (and HEAD) into a temporary directory and executes a
6
+ command on that checkout. It's primarily intended to create a package (gem,
7
+ war, etc.) of a clean copy of a project at a given tag.
8
+
9
+ More to come as I port some of my other stuff to ruby. =)
10
+
11
+
12
+ LICENSE:
13
+
14
+ git-utils is copyrighted free software by Jonathan D. Simms <slyphon AT gmail DOT com>.
15
+ You can redistribute it and/or modify it under either the terms of the GPL, or
16
+ the conditions below:
17
+
18
+ 1. You may make and give away verbatim copies of the source form of the
19
+ software without restriction, provided that you duplicate all of the
20
+ original copyright notices and associated disclaimers.
21
+
22
+ 2. You may modify your copy of the software in any way, provided that
23
+ you do at least ONE of the following:
24
+
25
+ a) place your modifications in the Public Domain or otherwise
26
+ make them Freely Available, such as by posting said
27
+ modifications to Usenet or an equivalent medium, or by allowing
28
+ the author to include your modifications in the software.
29
+
30
+ b) use the modified software only within your corporation or
31
+ organization.
32
+
33
+ c) rename any non-standard executables so the names do not conflict
34
+ with standard executables, which must also be provided.
35
+
36
+ d) make other distribution arrangements with the author.
37
+
38
+ 3. You may distribute the software in object code or executable
39
+ form, provided that you do at least ONE of the following:
40
+
41
+ a) distribute the executables and library files of the software,
42
+ together with instructions (in the manual page or equivalent)
43
+ on where to get the original distribution.
44
+
45
+ b) accompany the distribution with the machine-readable source of
46
+ the software.
47
+
48
+ c) give non-standard executables non-standard names, with
49
+ instructions on where to get the original software distribution.
50
+
51
+ d) make other distribution arrangements with the author.
52
+
53
+ 4. You may modify and include the part of the software into any other
54
+ software (possibly commercial). But some files in the distribution
55
+ are not written by the author, so that they are not under this terms.
56
+
57
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
58
+ files under the ./missing directory. See each file for the copying
59
+ condition.
60
+
61
+ 5. The scripts and library files supplied as input to or produced as
62
+ output from the software do not automatically fall under the
63
+ copyright of the software, but belong to whomever generated them,
64
+ and may be sold commercially, and may be aggregated with this
65
+ software.
66
+
67
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
68
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
69
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
70
+ PURPOSE.
71
+
72
+
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'tmpdir'
5
+ require 'fileutils'
6
+
7
+ class CleanRoom
8
+ include FileUtils
9
+
10
+ HELP = <<-EOS
11
+ Usage: #{File.basename($0)} [opts] command
12
+
13
+ Clone the current HEAD (or 'treeish' if the -t option is given) into a
14
+ temporary directory then runs command. The command given will be run in a
15
+ subshell, so it will be subject globbing/expansion
16
+
17
+ Exits with the status of command, the temp directory will be removed when
18
+ command exits
19
+
20
+ Options:
21
+
22
+ EOS
23
+
24
+ SHELL = ENV['SHELL']
25
+
26
+ attr_reader :tmpdir
27
+
28
+ def initialize
29
+ now = Time.now
30
+ timestamp = now.strftime("%Y%m%d%H%M%S_#{now.tv_usec}")
31
+
32
+ @tree = nil
33
+ @tmpdir = File.join(Dir.tmpdir, "#{File.basename(Dir.getwd)}_#{$$}.#{timestamp}")
34
+ end
35
+
36
+ def optparse
37
+ @optparse ||= OptionParser.new do |o|
38
+ o.banner = HELP
39
+ o.on('-t', '--treeish ARG', 'the treeish (branch,tag) to clone into a tmp dir') { |t| @tree = t }
40
+ o.on('-h', '--help', "you're reading it") { help! }
41
+ end
42
+ end
43
+
44
+ def help!
45
+ $stderr.puts optparse
46
+ exit 1
47
+ end
48
+
49
+ def sh(*cmd)
50
+ raise "command failed: #{cmd.join(' ')}" unless system(*cmd)
51
+ end
52
+
53
+ def main
54
+ optparse.parse!
55
+ help! if ARGV.empty?
56
+
57
+ @tree ||= `git symbolic-ref HEAD`.chomp.sub(%r%^refs/heads/%, '')
58
+
59
+ sh("git clone -- #{Dir.getwd} #{tmpdir}")
60
+
61
+ cd(tmpdir) do
62
+
63
+ if @tree != 'master'
64
+ remote = "origin/#{@tree}"
65
+ sh("git co --track -b #{@tree} #{remote}")
66
+ end
67
+
68
+ pid = fork do
69
+ exec(ARGV.join(' '))
70
+ end
71
+
72
+ _, st = Process.wait2(pid)
73
+
74
+ exit(st.exitstatus || 254)
75
+ end
76
+ ensure
77
+ rm_rf(tmpdir)
78
+ end
79
+ end
80
+
81
+ CleanRoom.new.main
@@ -0,0 +1,3 @@
1
+ module SlyphonGitUtils
2
+ end
3
+
@@ -0,0 +1,3 @@
1
+ module SlyphonGitUtils
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "slyphon-git-utils/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "slyphon-git-utils"
7
+ s.version = SlyphonGitUtils::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Jonathan D. Simms"]
10
+ s.email = ["slyphon %nospam% gmail.com"]
11
+ s.homepage = "http://github.org/slyphon/git-utils"
12
+ s.summary = 'A collection of git command-line utilities written in ruby'
13
+ s.description = 'A collection of git command-line utilities written in ruby'
14
+
15
+ s.rubyforge_project = "slyphon-git-utils"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slyphon-git-utils
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jonathan D. Simms
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-22 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A collection of git command-line utilities written in ruby
23
+ email:
24
+ - slyphon %nospam% gmail.com
25
+ executables:
26
+ - git-cleanroom
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README
35
+ - Rakefile
36
+ - bin/git-cleanroom
37
+ - lib/slyphon-git-utils.rb
38
+ - lib/slyphon-git-utils/version.rb
39
+ - slyphon-git-utils.gemspec
40
+ has_rdoc: true
41
+ homepage: http://github.org/slyphon/git-utils
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: slyphon-git-utils
70
+ rubygems_version: 1.3.7
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: A collection of git command-line utilities written in ruby
74
+ test_files: []
75
+