Skip to content

Commit

Permalink
Use back web interface to get rpm git info
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuhao Wan authored and Zuhao Wan committed Jun 17, 2012
1 parent 34fb4e5 commit dcc62bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 36 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Expand Up @@ -21,6 +21,4 @@ doc/
*~
nohup.out
.project
.DS_Store

rpmgit/
.DS_Store
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -18,7 +18,7 @@ gem 'jquery-rails'
gem 'haml'
gem 'execjs'
# gem 'grit'
gem 'git' # ruby-git seems to have better support on remote repo than grit
# gem 'git' # ruby-git seems to have better support on remote repo than grit


# To use ActiveModel has_secure_password
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.lock
Expand Up @@ -40,7 +40,6 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
git (1.2.5)
haml (3.1.4)
hike (1.2.1)
i18n (0.6.0)
Expand Down Expand Up @@ -110,7 +109,6 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
execjs
git
haml
jquery-rails
rails (= 3.2.3)
Expand Down
49 changes: 19 additions & 30 deletions app/models/rpm_importer.rb
@@ -1,42 +1,31 @@
require 'open-uri'
require 'git'

class RpmImporter

GIT_BASE_URI = 'git://pkgs.fedoraproject.org/'
FEDORAPKG_URI = 'http://pkgs.fedoraproject.org/gitweb/?a=project_index'
RPM_GIT_DIR = 'rpmgit'

def self.import
self.init
URI.parse(FEDORAPKG_URI).read.scan(/rubygem-.+\.git\s/).each do |index|
rpm_git_uri = GIT_BASE_URI + index
index.scan(/(.+)\.git/)
@rpm_repos.add_remote($1, rpm_git_uri)
end
BASE_URI = 'http://pkgs.fedoraproject.org/gitweb/?' #p=BackupPC.git;a=blob_plain;f=BackupPC.spec
PKG_LIST_URI = BASE_URI + 'a=project_index'
RPM_SPEC_URI = BASE_URI + 'a=blob_plain'

def self.import
# TODO: handle duplicates eg rubygem-foreigner.git vs rubygem-foreigner.git.sav

@rpm_repos.remotes.each do|rpm_git_repo|
rpm_git_repo.fetch
Rpm.new_from_rpm_tuple({:name => rpm_git_repo.name,
:git_url => rpm_git_repo.url,
:last_commit_message => rpm_git_repo.branch.gcommit.message,
:author => rpm_git_repo.branch.gcommit.author.name,
:last_committer => rpm_git_repo.branch.gcommit.committer.name,
:last_commit_sha => rpm_git_repo.branch.gcommit.sha,
:last_commit_date => rpm_git_repo.branch.gcommit.committer_date,
:ruby_gem_id => RubyGem.find_by_name(rpm_git_repo.name.gsub(/rubygem-/,'')).id})
URI.parse(PKG_LIST_URI).read.scan(/rubygem-.+\.git\s/).each do |rpm|
rpm_spec = URI.parse("#{RPM_SPEC_URI};p=#{rpm};f=#{rpm.gsub(/git$/,'spec')}")

end

# @rpm_repos.remotes.each do|rpm_git_repo|
# rpm_git_repo.fetch
# Rpm.new_from_rpm_tuple({:name => rpm_git_repo.name,
# :git_url => rpm_git_repo.url,
# :last_commit_message => rpm_git_repo.branch.gcommit.message,
# :author => rpm_git_repo.branch.gcommit.author.name,
# :last_committer => rpm_git_repo.branch.gcommit.committer.name,
# :last_commit_sha => rpm_git_repo.branch.gcommit.sha,
# :last_commit_date => rpm_git_repo.branch.gcommit.committer_date,
# :ruby_gem_id => RubyGem.find_by_name(rpm_git_repo.name.gsub(/rubygem-/,'')).id})
# end
rescue Exception => ex
puts ex.message
end

def self.init
Dir.mkdir(RPM_GIT_DIR) if !File.directory?(RPM_GIT_DIR)
FileUtils.remove_dir(RPM_GIT_DIR + '/.git') if File.directory?(RPM_GIT_DIR + '/.git')
FileUtils.cd(RPM_GIT_DIR)
@rpm_repos = Git.init
end

end

0 comments on commit dcc62bf

Please sign in to comment.