diff --git a/app/controllers/repohooks_controller.rb b/app/controllers/repohooks_controller.rb new file mode 100644 index 0000000..20c43f1 --- /dev/null +++ b/app/controllers/repohooks_controller.rb @@ -0,0 +1,60 @@ +class RepohooksController < ApplicationController + def new + @repohook = Repohook.new + end + + def create + @repohook = Repohook.new(params[:repohook]) + if @repohook.save + redirect_to root_url, :notice => "Repohook relation created!" + else + render "new" + end + end + + def destroy + @repohook = Repohook.find(params[:id]) + @repohook.destroy + respond_to do |format| + format.html { redirect_to repositories_path } + format.json { head :no_content } + end + end + +def index + @repohook = Repohook.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @repohook } + end + end + + def edit + @repohook = Repohook.find(params[:id]) + end + + def show + @repohook = Repohook.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @repohook } + end + end + + def update + @repohook = Repohook.find(params[:id]) + + respond_to do |format| + if @repohook.update_attributes(params[:repository]) + format.html { redirect_to hooktorepos_path, notice: 'Repohook was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @repohook.errors, status: :unprocessable_entity } + end + end + end + +end diff --git a/app/models/repohook.rb b/app/models/repohook.rb new file mode 100644 index 0000000..7124682 --- /dev/null +++ b/app/models/repohook.rb @@ -0,0 +1,4 @@ +class Repohook < ActiveRecord::Base + attr_accessible :hook_name, :repository_id + belongs_to :repository +end diff --git a/app/views/repohooks/_form.html.erb b/app/views/repohooks/_form.html.erb new file mode 100644 index 0000000..50543a4 --- /dev/null +++ b/app/views/repohooks/_form.html.erb @@ -0,0 +1,25 @@ +<%= form_for(@repohook) do |f| %> + <% if @repohook.errors.any? %> +
+

<%= pluralize(@repohook.errors.count, "error") %> prohibited this relation from being saved:

+ + +
+ <% end %> + +
+ <%= f.label :hook_name %>
+ <%= f.text_field :hook_name %> +
+
+ <%= f.label :repository_id %>
+ <%= f.text_field :repository_id %> +
+
+ <%= f.submit %> +
+<% end %> diff --git a/app/views/repohooks/create.html.erb b/app/views/repohooks/create.html.erb new file mode 100644 index 0000000..6a1122d --- /dev/null +++ b/app/views/repohooks/create.html.erb @@ -0,0 +1,2 @@ +

Hooktorepos#create

+

Find me in app/views/hooktorepos/create.html.erb

diff --git a/app/views/repohooks/destroy.html.erb b/app/views/repohooks/destroy.html.erb new file mode 100644 index 0000000..670c145 --- /dev/null +++ b/app/views/repohooks/destroy.html.erb @@ -0,0 +1,2 @@ +

Hooktorepos#destroy

+

Find me in app/views/hooktorepos/destroy.html.erb

diff --git a/app/views/repohooks/edit.html.erb b/app/views/repohooks/edit.html.erb new file mode 100644 index 0000000..3467e53 --- /dev/null +++ b/app/views/repohooks/edit.html.erb @@ -0,0 +1,6 @@ +

Editing relation

+ +<%= render 'form' %> + +<%= link_to 'Show', @repohook %> | +<%= link_to 'Back', repohooks_path %> diff --git a/app/views/repohooks/index.html.erb b/app/views/repohooks/index.html.erb new file mode 100644 index 0000000..59ed9e1 --- /dev/null +++ b/app/views/repohooks/index.html.erb @@ -0,0 +1,21 @@ +

Listing relations

+ + + + + + + +<% @repohook.each do |f| %> + + + + + + +<% end %> +
Name
<%= f.id %><%= link_to 'Show', f %><%= link_to 'Edit', edit_repohook_path(f) %><%= link_to 'Destroy', f, confirm: 'Are you sure?', method: :delete %>
+ +
+ +<%= link_to 'New Relation', new_repohook_path %> diff --git a/app/views/repohooks/new.html.erb b/app/views/repohooks/new.html.erb new file mode 100644 index 0000000..0955d6c --- /dev/null +++ b/app/views/repohooks/new.html.erb @@ -0,0 +1,12 @@ +

RepoHook#new

+<%= form_for @repohook do |f| %> +

+ <%= f.label :repository_id %> + <%= f.collection_select :repository_id, Repository.all, :id, :repo_name %> +

+

+ <%= f.label :hook_name %> + <%= f.text_field :hook_name %> +

+

<%= f.submit %>

+<% end %> diff --git a/app/views/repohooks/show.html.erb b/app/views/repohooks/show.html.erb new file mode 100644 index 0000000..dff22b3 --- /dev/null +++ b/app/views/repohooks/show.html.erb @@ -0,0 +1,17 @@ +

<%= notice %>

+ +

+ Relation id:
+ <%= @repohook.id %> +

+

+ Hook name:
+ <%= @repohook.hook_name %> +

+

+ Repository id:
+ <%= @repohook.repository_id %> +

+ +<%= link_to 'Edit', edit_repohook_path(@repohook) %> | +<%= link_to 'Back', repohooks_path %> diff --git a/app/views/repohooks/update.html.erb b/app/views/repohooks/update.html.erb new file mode 100644 index 0000000..d774121 --- /dev/null +++ b/app/views/repohooks/update.html.erb @@ -0,0 +1,2 @@ +

Hooktorepos#update

+

Find me in app/views/hooktorepos/update.html.erb

diff --git a/db/migrate/20130513131839_create_repohooks.rb b/db/migrate/20130513131839_create_repohooks.rb new file mode 100644 index 0000000..be6553a --- /dev/null +++ b/db/migrate/20130513131839_create_repohooks.rb @@ -0,0 +1,14 @@ +class CreateRepohooks < ActiveRecord::Migration + def change + create_table :repohooks do |t| + t.string :hook_name + t.references :repository + + t.timestamps + end + end + + def self.down + drop_table :repohooks + end +end diff --git a/test.tmpl b/test.tmpl new file mode 100644 index 0000000..50c15fc --- /dev/null +++ b/test.tmpl @@ -0,0 +1,51 @@ +#!/bin/sh +abcdef +# POST-COMMIT HOOK +# +# The post-commit hook is invoked after a commit. Subversion runs +# this hook by invoking a program (script, executable, binary, etc.) +# named 'post-commit' (for which this file is a template) with the +# following ordered arguments: +# +# [1] REPOS-PATH (the path to this repository) +# [2] REV (the number of the revision just committed) +# +# The default working directory for the invocation is undefined, so +# the program should set one explicitly if it cares. +# +# Because the commit has already completed and cannot be undone, +# the exit code of the hook program is ignored. The hook program +# can use the 'svnlook' utility to help it examine the +# newly-committed tree. +# +# On a Unix system, the normal procedure is to have 'post-commit' +# invoke other programs to do the real work, though it may do the +# work itself too. +# +# Note that 'post-commit' must be executable by the user(s) who will +# invoke it (typically the user httpd runs as), and that user must +# have filesystem-level permission to access the repository. +# +# On a Windows system, you should name the hook program +# 'post-commit.bat' or 'post-commit.exe', +# but the basic idea is the same. +# +# The hook program typically does not inherit the environment of +# its parent process. For example, a common problem is for the +# PATH environment variable to not be set to its usual value, so +# that subprograms fail to launch unless invoked via absolute path. +# If you're having unexpected problems with a hook program, the +# culprit may be unusual (or missing) environment variables. +# +# Here is an example hook script, for a Unix /bin/sh interpreter. +# For more examples and pre-written hooks, see those in +# the Subversion repository at +# http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and +# http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ + + +REPOS="$1" +REV="$2" + +commit-email.pl "$REPOS" "$REV" commit-watchers@example.org +log-commit.py --repository "$REPOS" --revision "$REV"