Sha256: 7918f2580b19dddfc929f9559f533b3e56de287fe4b567ec8759a27e488c0fe6

Contents?: true

Size: 878 Bytes

Versions: 10

Compression:

Stored size: 878 Bytes

Contents

module ModuleSync
  module Hook
    include Constants

    def self.activate(args)
      repo = args[:configs]
      hook_args = ''
      hook_args <<= " -n #{args[:namespace]}" if args[:namespace]
      hook_args <<= " -b #{args[:branch]}" if args[:branch]
      hook = <<EOF
#!/usr/bin/env bash

current_branch=\`git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,'\`
git_dir=\`git rev-parse --show-toplevel\`
message=\`git log -1 --format=%B\`
msync -m "\$message"#{hook_args}
EOF
      File.open("#{repo}/#{HOOK_FILE}", 'w') do |file|
        file.write(hook)
      end
    end

    def self.deactivate(repo)
      hook_path = "#{repo}/#{HOOK_FILE}"
      File.delete(hook_path) if File.exists?(hook_path)
    end

    def self.hook(command, args)
      if (command == 'activate')
        activate(args)
      else
        deactivate(args[:configs])
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
modulesync-0.6.1 lib/modulesync/hook.rb
modulesync-0.6.0 lib/modulesync/hook.rb
modulesync-0.5.0 lib/modulesync/hook.rb
modulesync-0.4.0 lib/modulesync/hook.rb
modulesync-0.3.0 lib/modulesync/hook.rb
modulesync-0.2.0 lib/modulesync/hook.rb
modulesync-0.1.0 lib/modulesync/hook.rb
modulesync-0.0.3 lib/modulesync/hook.rb
modulesync-0.0.2 lib/modulesync/hook.rb
modulesync-0.0.1 lib/modulesync/hook.rb