Permalink
Browse files

started working on extracting info from git repo

  • Loading branch information...
1 parent 1b8c409 commit 0004a35f2e0cf7336f2b475ed4f523a839e6822e Michael Nutt committed Oct 20, 2009
Showing with 32 additions and 2 deletions.
  1. +32 −2 lib/quick_git_help/tutorial.rb
@@ -8,11 +8,41 @@ class Tutorial
def initialize(dir)
@repo_path = dir
+ @repo = Repo.new(@repo_path)
+ end
+
+ def tutorial_dir
+ File.join(@repo_path, 'quick_tutorial')
+ end
+
+ def make_tutorial_dir
+ FileUtils.rm_rf(tutorial_dir)
+ FileUtils.mkdir(tutorial_dir)
+ end
+
+ def write_tutorial_dirs
+ @repo.commits.each do |commit|
+ FileUtils.mkdir(File.join(tutorial_dir, commit.sha))
+ commit.diffs.each do |diff|
+ path = diff.a_path
+ puts path
+ data = diff.a_blob.data
+ File.open(File.join(tutorial_dir, commit.sha, path), 'w') do |f|
+ f.write(data)
+ end
+ end
+ end
+ end
+
+ def guess_file_path
+ @repo.commits.last.diffs.first.b_path
end
def create
- repo = Repo.new(@repo_path)
- puts repo.inspect
+ make_tutorial_dir
+ write_tutorial_dirs
+ @tutorial_file = guess_file_path
+ puts @tutorial_file
end
end
end

0 comments on commit 0004a35

Please sign in to comment.