list of changes and commit on current branch
This commit is contained in:
parent
d7f55540b3
commit
236d10a768
@ -1,11 +1,23 @@
|
|||||||
require "rugged"
|
require "git"
|
||||||
|
|
||||||
module Merged
|
module Merged
|
||||||
class ChangesController < MergedController
|
class ChangesController < MergedController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@git = Rugged::Repository.new(Rails.root)
|
@git = Git.open(Rails.root)
|
||||||
|
@status = @git.status()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def commit
|
||||||
|
raise "must have message" if params[:message].blank?
|
||||||
|
git = Git.open(Rails.root)
|
||||||
|
git.add("cms")
|
||||||
|
git.add("app/assets/images/cms")
|
||||||
|
begin
|
||||||
|
git.commit(params[:message])
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
redirect_to changes_index_url
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,46 @@
|
|||||||
%p= @git.workdir
|
.flex.flex-col.bg-white
|
||||||
%p Lines Changed
|
.flex.items-center.justify-center.flex-1
|
||||||
-@git.diff_workdir("HEAD").each_line do |line|
|
.max-w-xl.px-4.py-8.mx-auto.text-center
|
||||||
%p= line.content
|
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
||||||
%h3 Patches
|
Changes
|
||||||
%h3 Patches
|
%p.mt-4.text-gray-500
|
||||||
%h3 Patches
|
Branch
|
||||||
-@git.diff_workdir("HEAD").each_patch do |patch|
|
= @git.current_branch
|
||||||
%p= patch.additions
|
|
||||||
-patch.each_hunk do |hunk|
|
.grid.grid-cols-4.gap-2.m-8
|
||||||
%p=hunk.header
|
.relative.block.border.border-gray-100
|
||||||
-hunk.each_line do |line|
|
Changed Files
|
||||||
%p= line.content
|
-@status.changed.each do |name , file|
|
||||||
|
-next unless name.include?("cms")
|
||||||
|
%p
|
||||||
|
= name
|
||||||
|
|
||||||
|
.relative.block.border.border-gray-100
|
||||||
|
Deletions
|
||||||
|
-@status.deleted.each do |name , file|
|
||||||
|
-next unless name.include?("cms")
|
||||||
|
%p= name
|
||||||
|
.relative.block.border.border-gray-100
|
||||||
|
Additions
|
||||||
|
-@status.added.each do |name , file|
|
||||||
|
-next unless name.include?("cms")
|
||||||
|
%p= name
|
||||||
|
.relative.block.border.border-gray-100
|
||||||
|
New
|
||||||
|
-@status.untracked.each do |name , file|
|
||||||
|
-next if name.starts_with?("merged")
|
||||||
|
-next unless name.include?("cms")
|
||||||
|
%p
|
||||||
|
= name
|
||||||
|
|
||||||
|
.flex.flex-col.bg-white
|
||||||
|
.flex.items-center.justify-center.flex-1
|
||||||
|
.max-w-xl.px-4.py-8.mx-auto.text-center
|
||||||
|
= form_tag( changes_commit_url() , {method: :post } ) do
|
||||||
|
%h1.text-2xl.font-bold.tracking-tight.text-gray-900.sm:text-4xl
|
||||||
|
Commit changes
|
||||||
|
%p.mt-4.text-gray-500
|
||||||
|
%label.block
|
||||||
|
%h4.text-lg.font-bold Message (short summary of changes)
|
||||||
|
= text_field_tag( :message , "", class: "block w-full rounded-lg border-gray-200 p-4 pr-12 text-sm shadow-sm")
|
||||||
|
=submit_button( "Commit")
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
Merged::Engine.routes.draw do
|
Merged::Engine.routes.draw do
|
||||||
|
|
||||||
get 'changes/index'
|
get 'changes/index'
|
||||||
|
post 'changes/commit'
|
||||||
get "styles/index"
|
get "styles/index"
|
||||||
|
|
||||||
resources :pages , except: [:show] , shallow: true do
|
resources :pages , except: [:show] , shallow: true do
|
||||||
|
@ -20,5 +20,5 @@ Gem::Specification.new do |spec|
|
|||||||
|
|
||||||
spec.add_dependency "rails", ">= 7.0.4"
|
spec.add_dependency "rails", ">= 7.0.4"
|
||||||
spec.add_dependency "haml-rails"
|
spec.add_dependency "haml-rails"
|
||||||
spec.add_dependency "rugged"
|
spec.add_dependency "git"
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user