publicity 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -85,7 +85,7 @@ EOS
85
85
  dir = "#{tmpdir}/#{remote_repo[:name]}.git"
86
86
 
87
87
  # Clone the original repo
88
- `git clone --bare #{remote_repo.clone_url} #{dir} 1> /dev/null`
88
+ `git clone #{remote_repo.clone_url} #{dir} 1> /dev/null`
89
89
 
90
90
  puts "Finished cloning."
91
91
 
@@ -94,7 +94,10 @@ EOS
94
94
 
95
95
  # Get a list of all the branches, and filter out irrelevant branches
96
96
  regex = /(#{Regexp.quote(@username)}|master)/
97
- branches = Rugged::Branch.each_name(local_repo).sort.select { |branch| branch =~ regex }
97
+ branches = Rugged::Branch.each_name(local_repo, :remote)
98
+ .sort
99
+ .select { |branch| branch =~ regex }
100
+ .each { |i| i.gsub!(/origin\//, '') }
98
101
 
99
102
  # Ask the user which branch they want to keep; we'll end up deleting
100
103
  # all other branches. Skip over this prompt if the repo only has a
@@ -132,7 +135,7 @@ EOS
132
135
  # Delete all remote branches
133
136
  Rugged::Branch.each_name(local_repo, :remote).sort.each do |r|
134
137
  if not r =~ /^master$/
135
- Rugged::Branch.lookup(local_repo, r).delete!
138
+ Rugged::Branch.lookup(local_repo, r).delete! if Rugged::Branch.lookup(local_repo, r)
136
139
  end
137
140
  end
138
141
 
@@ -284,19 +287,18 @@ For a better perspective on my own work, please see #{data[:name]}(#{data[:url]}
284
287
  EOS
285
288
 
286
289
  oid = repo.write(text, :blob)
287
- index = Rugged::Index.new
290
+ index = repo.index
288
291
  index.add(:path => "README.md", :oid => oid, :mode => 0100644)
289
292
 
290
- options = {}
291
- options[:tree] = index.write_tree(repo)
293
+ author = { :email => "accounts@hackreactor.com", :name => 'Hack Reactor', :time => Time.now }
292
294
 
293
- options[:author] = { :email => "accounts@hackreactor.com", :name => 'Hack Reactor', :time => Time.now }
294
- options[:committer] = { :email => "accounts@hackreactor.com", :name => 'Hack Reactor', :time => Time.now }
295
- options[:message] ||= "Added an automatically generated readme"
296
- options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
297
- options[:update_ref] = 'HEAD'
298
-
299
- Rugged::Commit.create(repo, options)
295
+ Rugged::Commit.create(repo,
296
+ :tree => repo.lookup(repo.index.write_tree),
297
+ :author => author,
298
+ :committer => author,
299
+ :message => "Add a readme (automated commit)",
300
+ :parents => repo.empty? ? [] : [repo.head.target].compact,
301
+ :update_ref => 'HEAD')
300
302
  end
301
303
  end
302
304
  end
@@ -1,3 +1,3 @@
1
1
  module Publicity
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: publicity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-03 00:00:00.000000000 Z
12
+ date: 2013-05-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler