Change Update Manager to work with tags
This commit is contained in:
parent
a308171f31
commit
e6ec7b3008
|
@ -3,7 +3,8 @@ class Admin::SitesController < OrbitBackendController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
before_filter :is_admin?
|
before_filter :is_admin?
|
||||||
before_filter :get_site
|
before_filter :get_site
|
||||||
before_filter :git_branch
|
before_filter :git_branch, only: [:update_manager, :get_update_history, :check_updates, :update_orbit]
|
||||||
|
before_filter :git_tags, only: [:update_manager, :get_update_history, :check_updates, :update_orbit]
|
||||||
|
|
||||||
# def index
|
# def index
|
||||||
# @site = Site.first
|
# @site = Site.first
|
||||||
|
@ -132,8 +133,10 @@ class Admin::SitesController < OrbitBackendController
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_updates
|
def check_updates
|
||||||
|
if (@current_tag.eql?(@latest_tag) == false)
|
||||||
%x(git fetch origin)
|
%x(git fetch origin)
|
||||||
@new_updates = %x(git log #{@branch}..origin/#{@branch} --pretty=format:"%ad','%s" --date=short).split("\n").map{|log| log.gsub("'","").split(",")}.to_json
|
end
|
||||||
|
@new_updates = %x(git log "#{@current_tag}"..."#{@latest_tag}" --pretty=format:"%ad','%s" --date=short).split("\n").map{|log| log.gsub("'","").split(",")}.to_json
|
||||||
render :json => @new_updates
|
render :json => @new_updates
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -142,7 +145,7 @@ class Admin::SitesController < OrbitBackendController
|
||||||
need_stash = %x(git diff).blank?
|
need_stash = %x(git diff).blank?
|
||||||
%x(git stash) unless need_stash
|
%x(git stash) unless need_stash
|
||||||
%x(git fetch origin)
|
%x(git fetch origin)
|
||||||
pull_result = %x(git pull -r --ff-only 2>&1 origin #{@branch})
|
pull_result = %x(git pull -r --ff-only 2>&1 origin #{@latest_tag})
|
||||||
%x(git stash pop) unless need_stash
|
%x(git stash pop) unless need_stash
|
||||||
|
|
||||||
if pull_result.include? "fatal: Not possible to fast-forward, aborting."
|
if pull_result.include? "fatal: Not possible to fast-forward, aborting."
|
||||||
|
@ -186,4 +189,9 @@ class Admin::SitesController < OrbitBackendController
|
||||||
@branch = %x(git rev-parse --abbrev-ref HEAD).gsub("\n","")
|
@branch = %x(git rev-parse --abbrev-ref HEAD).gsub("\n","")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def git_tags
|
||||||
|
@current_tag = %x(git describe --tags).gsub("\n","")
|
||||||
|
@latest_tag = `git ls-remote --tags origin | awk '{print $2}'`.split(/\n/).last.gsub("refs/tags/","")
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue