Class: Jekyll::Repository
- Inherits:
-
Object
- Object
- Jekyll::Repository
- Defined in:
- lib/jekyll/repository.rb
Overview
Super basic access to the Git repository, only useful for commiting changes.
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#commit(message, author = jekyll_author) ⇒ String
Commit changes to repository, first add files to the commit index, then write changes to reflect the current state (otherwise the file will be commited but missing from disk (?)) and then create a commit.
-
#initialize(site) ⇒ Repository
constructor
A new instance of Repository.
- #jekyll_author ⇒ Object
Constructor Details
#initialize(site) ⇒ Repository
Returns a new instance of Repository.
9 10 11 12 13 14 15 |
# File 'lib/jekyll/repository.rb', line 9 def initialize(site) require 'rugged' @site = site @path = site.source @git = Rugged::Repository.new(path) end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
7 8 9 |
# File 'lib/jekyll/repository.rb', line 7 def git @git end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/jekyll/repository.rb', line 7 def path @path end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
7 8 9 |
# File 'lib/jekyll/repository.rb', line 7 def site @site end |
Instance Method Details
#commit(message, author = jekyll_author) ⇒ String
Commit changes to repository, first add files to the commit index, then write changes to reflect the current state (otherwise the file will be commited but missing from disk (?)) and then create a commit.
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jekyll/repository.rb', line 25 def commit(, = ) site.staged_files.each do |file| git.index.add(real_path file) end git.index.write Rugged::Commit.create(git, message: , update_ref: 'HEAD', parents: [git.head.target], tree: git.index.write_tree, author: , committer: ) end |
#jekyll_author ⇒ Object
39 40 41 |
# File 'lib/jekyll/repository.rb', line 39 def @jekyll_author ||= { name: 'Jekyll', email: 'jekyll@localhost', time: Time.now } end |