oleg 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf6dc4d35d1d56ccd42336c8823eed7084bdc3e2
4
- data.tar.gz: 7e606d646f3bb7e4813a883d9d77f6a6d1aecd36
3
+ metadata.gz: 1959ad4dcb10af988cca489723033a91a9ff9dd5
4
+ data.tar.gz: a376caa659e4830dfc91ad8137ef62f752a6ecd4
5
5
  SHA512:
6
- metadata.gz: 5eecfdee1f304905f0103913c4b6f50b8a63c50a0f51ed3eae3c57f709bc5091a6cfac72b3fc352dc38a30f34e2a947fe7d8b9f025b753635a62efae28c0913e
7
- data.tar.gz: 93e50b46cb0b4ddb905b3744e5b2c4461f37ca5c385a6809d6dd9b54f08744296f88e615dbf7fdfa5de7e0f4f461c7f433071e03bef39a87b0ed6b1831c7a450
6
+ metadata.gz: 4b20e1e39fe317138b9b6d61156026c59b6836984f7046239b71a422745463a820207b5436fbc15feb175de31801e21b27b07b158b4f56ba956adf8c75e4a8ad
7
+ data.tar.gz: 4dbeceee4d089a6e7e16bd2d0cd0281b2f1e8a34760a81d62c79f26d4d50630446e5fda29efb03a1114aa03bb40d3294b580ae561851da918251327dbfa3f04e
@@ -58,8 +58,10 @@ class Leg::Commands::Repo < Leg::Commands::BaseCommand
58
58
 
59
59
  File.write("repo/.git/hooks/post-commit", POST_COMMIT_HOOK)
60
60
  File.write("repo/.git/hooks/prepare-commit-msg", PREPARE_COMMIT_MSG_HOOK)
61
+ File.write("repo/.git/hooks/post-rewrite", POST_REWRITE_HOOK)
61
62
  FileUtils.chmod(0755, "repo/.git/hooks/post-commit")
62
63
  FileUtils.chmod(0755, "repo/.git/hooks/prepare-commit-msg")
64
+ FileUtils.chmod(0755, "repo/.git/hooks/post-rewrite")
63
65
 
64
66
  FileUtils.rm_r(steps)
65
67
  end
@@ -67,6 +69,8 @@ class Leg::Commands::Repo < Leg::Commands::BaseCommand
67
69
  POST_COMMIT_HOOK = <<~'EOF'
68
70
  #!/usr/bin/env ruby
69
71
 
72
+ exit if File.exist?(File.join(ENV['GIT_DIR'], '.git/rebase-merge'))
73
+
70
74
  require 'rugged'
71
75
 
72
76
  repo = Rugged::Repository.discover
@@ -76,13 +80,20 @@ class Leg::Commands::Repo < Leg::Commands::BaseCommand
76
80
  tags << parts.join('-') unless parts.empty?
77
81
 
78
82
  tags.each do |tag|
79
- repo.references.create("refs/tags/#{tag}", commit.oid)
83
+ unless repo.tags[tag]
84
+ repo.references.create("refs/tags/#{tag}", commit.oid)
85
+ end
80
86
  end
81
87
  EOF
82
88
 
83
89
  PREPARE_COMMIT_MSG_HOOK = <<~'EOF'
84
90
  #!/usr/bin/env ruby
85
91
 
92
+ exit if File.exist?(File.join(ENV['GIT_DIR'], '.git/rebase-merge'))
93
+
94
+ msg = File.read(ARGV[0])
95
+ exit if !msg.lines.first.strip.empty?
96
+
86
97
  require 'rugged'
87
98
 
88
99
  repo = Rugged::Repository.discover
@@ -105,5 +116,25 @@ class Leg::Commands::Repo < Leg::Commands::BaseCommand
105
116
  File.write(ARGV[0], msg)
106
117
  end
107
118
  EOF
119
+
120
+ POST_REWRITE_HOOK = <<~'EOF'
121
+ #!/usr/bin/env ruby
122
+
123
+ require 'rugged'
124
+
125
+ repo = Rugged::Repository.discover
126
+
127
+ tags = {}
128
+ repo.tags.each do |tag|
129
+ tags[tag.target.oid] = tag.name
130
+ end
131
+
132
+ while line = $stdin.gets
133
+ old_sha1, new_sha1 = line.split
134
+ if tags[old_sha1]
135
+ repo.references.update("refs/tags/#{tags[old_sha1]}", new_sha1)
136
+ end
137
+ end
138
+ EOF
108
139
  end
109
140
 
@@ -19,21 +19,16 @@ class Leg::Commands::Unrepo < Leg::Commands::BaseCommand
19
19
 
20
20
  repo = Rugged::Repository.new("repo")
21
21
 
22
- tag_names = {}
23
- repo.tags.each do |tag|
24
- if tag.name !~ /\A\d+(\.\d+)*\z/
25
- tag_names[tag.target.oid] = tag.name
26
- end
27
- end
28
-
29
22
  walker = Rugged::Walker.new(repo)
30
23
  walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
31
24
  walker.push(repo.branches.find { |b| b.name == "master" }.target)
32
25
  walker.each.with_index do |commit, idx|
33
26
  step = (idx + 1).to_s
34
27
  step_name = step
35
- if tag_name = tag_names[commit.oid]
36
- step_name += "-#{tag_name}"
28
+
29
+ parts = commit.message.lines.first.strip.split('-')
30
+ if parts.length >= 2
31
+ step_name += "-#{parts[1..-1].join('-')}"
37
32
  end
38
33
 
39
34
  step_path = File.join(@config[:path], step_name)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oleg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ruten