mirror of
https://github.com/discourse/discourse.git
synced 2025-03-27 03:06:39 +08:00
strip out docker stuff, put into a plugin
This commit is contained in:
parent
2610bd0192
commit
8339337cd1
app
controllers/admin
views/admin/upgrade
config
lib/upgrade
@ -1,20 +0,0 @@
|
|||||||
# EXPERIMENTAL: front end for upgrading your instance using the web UI
|
|
||||||
|
|
||||||
class Admin::UpgradeController < Admin::AdminController
|
|
||||||
|
|
||||||
before_filter :ensure_admin
|
|
||||||
skip_before_filter :check_xhr
|
|
||||||
|
|
||||||
layout 'no_js'
|
|
||||||
|
|
||||||
def index
|
|
||||||
require_dependency 'upgrade/git_repo'
|
|
||||||
@main_repo = Upgrade::GitRepo.new(Rails.root)
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def ensure_admin
|
|
||||||
raise Discourse::InvalidAccess.new unless current_user.admin?
|
|
||||||
end
|
|
||||||
end
|
|
Binary file not shown.
@ -1,10 +0,0 @@
|
|||||||
<% if repo.valid? %>
|
|
||||||
Current version: <%= repo.latest_local_commit %> (<%= time_ago_in_words repo.latest_local_commit_date %> ago),
|
|
||||||
Remote version: <a href="<%= repo.url %>"><%= repo.latest_origin_commit %></a> (<%= time_ago_in_words repo.latest_origin_commit_date %> ago)
|
|
||||||
<% if repo.commits_behind > 0 %>
|
|
||||||
commits behind: <%= repo.commits_behind %>
|
|
||||||
<button action="">upgrade</button>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
Not under source control.
|
|
||||||
<% end %>
|
|
@ -1,18 +0,0 @@
|
|||||||
<h2>Discourse</h2>
|
|
||||||
<p>
|
|
||||||
<%= render partial: 'git_status', locals: {repo: @main_repo} %>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<h2>Plugins</h2>
|
|
||||||
<ul>
|
|
||||||
<% Discourse.plugins.each do |plugin| %>
|
|
||||||
<li>
|
|
||||||
<%= plugin.name %> -
|
|
||||||
<%= render partial: 'git_status', locals: {repo: Upgrade::GitRepo.new(File.dirname(plugin.path))} %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h2>Processes</h2>
|
|
||||||
|
|
||||||
<h2>Log</h2>
|
|
@ -97,9 +97,6 @@ Discourse::Application.routes.draw do
|
|||||||
delete 'key' => 'api#revoke_key'
|
delete 'key' => 'api#revoke_key'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get 'upgrade' => 'upgrade#index'
|
|
||||||
|
|
||||||
end # admin namespace
|
end # admin namespace
|
||||||
|
|
||||||
get 'email_preferences' => 'email#preferences_redirect', :as => 'email_preferences_redirect'
|
get 'email_preferences' => 'email#preferences_redirect', :as => 'email_preferences_redirect'
|
||||||
|
@ -1,69 +0,0 @@
|
|||||||
module Upgrade; end
|
|
||||||
|
|
||||||
# like Grit just very very minimal
|
|
||||||
class Upgrade::GitRepo
|
|
||||||
attr_reader :path
|
|
||||||
|
|
||||||
def initialize(path)
|
|
||||||
@path = path
|
|
||||||
@memoize = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
def valid?
|
|
||||||
File.directory?("#{path}/.git")
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_local_commit
|
|
||||||
run "rev-parse --short HEAD"
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_origin_commit
|
|
||||||
run "rev-parse --short #{tracking_branch}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_origin_commit_date
|
|
||||||
commit_date(latest_origin_commit)
|
|
||||||
end
|
|
||||||
|
|
||||||
def latest_local_commit_date
|
|
||||||
commit_date(latest_local_commit)
|
|
||||||
end
|
|
||||||
|
|
||||||
def commits_behind
|
|
||||||
run("rev-list --count #{tracking_branch}..HEAD").to_i
|
|
||||||
end
|
|
||||||
|
|
||||||
def url
|
|
||||||
url = run "config --get remote.origin.url"
|
|
||||||
if url =~ /^git/
|
|
||||||
# hack so it works with git urls
|
|
||||||
url = "https://github.com/#{url.split(":")[1]}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def commit_date(commit)
|
|
||||||
unix_timestamp = run('show -s --format="%ct" ' << commit).to_i
|
|
||||||
Time.at(unix_timestamp).to_datetime
|
|
||||||
end
|
|
||||||
|
|
||||||
def tracking_branch
|
|
||||||
run "for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD)"
|
|
||||||
end
|
|
||||||
|
|
||||||
def ensure_updated
|
|
||||||
@updated ||= Thread.new do
|
|
||||||
# this is a very slow operation, make it async
|
|
||||||
`cd #{path} && git remote update`
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def run(cmd)
|
|
||||||
ensure_updated
|
|
||||||
@memoize[cmd] ||= `cd #{path} && git #{cmd}`.strip
|
|
||||||
rescue => e
|
|
||||||
p e
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user