minad / olelo

Wiki with git backend
MIT License
241 stars 44 forks source link

Add after_commit hook #95

Closed bolasblack closed 10 years ago

bolasblack commented 10 years ago

Then i can write a plugin that make push commit after save page automatically.

# -*- coding: utf-8 -*-
description 'exec git push after save page'

Page.hook :after_commit do
  Olelo.logger.info "push git history after save page"
  git_path = Config[:repository][:git][:path]
  response = `git --git-dir=#{git_path} --bare push origin master 2>&1`
  if $?.success?
    Olelo.logger.info "git history push success"
  else
    Olelo.logger.error "git history push failure, reason: #{response}"
  end
end
minad commented 10 years ago

Why not add the Hook to the Page class?

bolasblack commented 10 years ago

@minad I'm new to Ruby, I don't know how to call instance method from class method

minad commented 10 years ago

Page hooks are also defined in the class. Basically you only have to define an after hook there

bolasblack commented 10 years ago

@minad i think that it's ok now

minad commented 10 years ago

Sry, seems to be ok. Thanks.