Skip to content

Commit

Permalink
a lot more tolerant of messed up repos
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Nov 7, 2008
1 parent 0f6159e commit 2a3b63f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
21 changes: 11 additions & 10 deletions commands/commands.rb
Expand Up @@ -54,24 +54,25 @@
data = get_network_data(user)
data['users'].each do |hsh|
u = hsh['name']
ids += hsh['heads'].map { |a| a['id'] }
user_ids = hsh['heads'].map { |a| a['id'] }
user_ids.each do |id|
if !helper.has_commit?(id)
GitHub.invoke(:track, u) unless helper.tracking?(u)
puts "fetching #{u}"
GitHub.invoke(:fetch_all, u)
end
end
ids += user_ids
end
ids.uniq!

# check that we have all these shas locally
ids.each do |id|
if !helper.has_commit?(id)
GitHub.invoke(:track, u) unless helper.tracking?(u)
puts "fetching #{u}"
GitHub.invoke(:fetch_all, u)
end
end


local_heads = helper.local_heads
local_heads_not = local_heads.map { |a| "^#{a}"}
looking_for = (ids - local_heads) + local_heads_not
commits = helper.get_commits(looking_for)

cherry = []
ids.each do |id|
cherry += helper.get_cherry(id)
Expand Down
4 changes: 2 additions & 2 deletions commands/helpers.rb
Expand Up @@ -39,7 +39,7 @@
end

helper :has_commit? do |sha|
`git rev-parse #{sha}`
`git show #{sha} >/dev/null 2>/dev/null`
$?.exitstatus == 0
end

Expand Down Expand Up @@ -79,7 +79,7 @@
end

helper :get_commits do |rev_array|
list = rev_array.join(' ')
list = rev_array.select { |a| has_commit?(a) }.join(' ')
`git log --pretty=format:"%H::%ae::%s::%ar::%ad" --no-merges #{list}`.split("\n").map { |a| a.split('::') }
end

Expand Down

0 comments on commit 2a3b63f

Please sign in to comment.