slyphon-git-utils 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/git-cleanroom +24 -10
- data/lib/slyphon-git-utils/version.rb +1 -1
- metadata +3 -3
data/bin/git-cleanroom
CHANGED
@@ -10,13 +10,18 @@ class CleanRoom
|
|
10
10
|
HELP = <<-EOS
|
11
11
|
Usage: #{File.basename($0)} [opts] command
|
12
12
|
|
13
|
-
Clone the current HEAD (
|
14
|
-
temporary directory then runs command. The command given will
|
15
|
-
subshell, so it will be subject globbing/expansion
|
13
|
+
Clone the current HEAD (tag if the -t option is given, branch if the -b option
|
14
|
+
is given) into a temporary directory then runs command. The command given will
|
15
|
+
be run in a subshell, so it will be subject globbing/expansion
|
16
|
+
|
17
|
+
If neither -t or -b options are given, will check out the current branch in the
|
18
|
+
tempdir (using git co -b --track).
|
16
19
|
|
17
20
|
Exits with the status of command, the temp directory will be removed when
|
18
21
|
command exits
|
19
22
|
|
23
|
+
Note: tag and branch options are mutually exclusive
|
24
|
+
|
20
25
|
Options:
|
21
26
|
|
22
27
|
EOS
|
@@ -29,14 +34,15 @@ Options:
|
|
29
34
|
now = Time.now
|
30
35
|
timestamp = now.strftime("%Y%m%d%H%M%S_#{now.tv_usec}")
|
31
36
|
|
32
|
-
@tree = nil
|
37
|
+
@tree = @tag = @branch = nil
|
33
38
|
@tmpdir = File.join(Dir.tmpdir, "#{File.basename(Dir.getwd)}_#{$$}.#{timestamp}")
|
34
39
|
end
|
35
40
|
|
36
41
|
def optparse
|
37
42
|
@optparse ||= OptionParser.new do |o|
|
38
43
|
o.banner = HELP
|
39
|
-
o.on('-t', '--
|
44
|
+
o.on('-t', '--tag ARG', 'the tag to switch to in the tmp dir (will be a detached HEAD)') { |t| @tag = t }
|
45
|
+
o.on('-b', '--branch ARG', 'the branch to switch to in the tmp dir (will be a tracking branch)') { |t| @branch = t }
|
40
46
|
o.on('-h', '--help', "you're reading it") { help! }
|
41
47
|
end
|
42
48
|
end
|
@@ -54,15 +60,23 @@ Options:
|
|
54
60
|
optparse.parse!
|
55
61
|
help! if ARGV.empty?
|
56
62
|
|
57
|
-
@
|
63
|
+
if @tag and @branch
|
64
|
+
$stderr.puts "ERROR: please specify only one of --tag or --branch"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
@tree = `git symbolic-ref HEAD`.chomp.sub(%r%^refs/heads/%, '')
|
69
|
+
|
70
|
+
$stderr.puts "tag: #{@tag.inspect}, branch: #{@branch.inspect}, tree: #{@tree.inspect}"
|
58
71
|
|
59
72
|
sh("git clone -- #{Dir.getwd} #{tmpdir}")
|
60
73
|
|
61
74
|
cd(tmpdir) do
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
75
|
+
if @tag
|
76
|
+
sh("git checkout refs/tags/#{@tag}")
|
77
|
+
elsif @branch or (@tree != 'master')
|
78
|
+
ref = @branch or @tree
|
79
|
+
sh("git checkout --track -b #{ref} origin/#{ref}")
|
66
80
|
end
|
67
81
|
|
68
82
|
pid = fork do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slyphon-git-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jonathan D. Simms
|