Merge pull request #147506 from talyz/discourse-2.8.0.beta8

discourse: 2.7.9 -> 2.8.0.beta9
This commit is contained in:
Kim Lindberger 2021-12-08 18:15:48 +01:00 committed by GitHub
commit 9bf94de535
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 655 additions and 510 deletions

View File

@ -621,12 +621,13 @@ in
max_user_api_reqs_per_minute = 20;
max_user_api_reqs_per_day = 2880;
max_admin_api_reqs_per_key_per_minute = 60;
max_admin_api_reqs_per_minute = 60;
max_reqs_per_ip_per_minute = 200;
max_reqs_per_ip_per_10_seconds = 50;
max_asset_reqs_per_ip_per_10_seconds = 200;
max_reqs_per_ip_mode = "block";
max_reqs_rate_limit_on_private = false;
skip_per_ip_rate_limit_trust_level = 1;
force_anonymous_min_queue_seconds = 1;
force_anonymous_min_per_10_seconds = 3;
background_requests_max_queue_length = 0.5;
@ -646,6 +647,9 @@ in
enable_email_sync_demon = false;
max_digests_enqueued_per_30_mins_per_site = 10000;
cluster_name = null;
multisite_config_path = "config/multisite.yml";
enable_long_polling = null;
long_polling_interval = null;
};
services.redis.enable = lib.mkDefault (cfg.redis.host == "localhost");
@ -825,7 +829,7 @@ in
appendHttpConfig = ''
# inactive means we keep stuff around for 1440m minutes regardless of last access (1 week)
# levels means it is a 2 deep heirarchy cause we can have lots of files
# levels means it is a 2 deep hierarchy cause we can have lots of files
# max_size limits the size of the cache
proxy_cache_path /var/cache/nginx inactive=1440m levels=1:2 keys_zone=discourse:10m max_size=600m;
@ -837,7 +841,7 @@ in
inherit (cfg) sslCertificate sslCertificateKey enableACME;
forceSSL = lib.mkDefault tlsEnabled;
root = "/run/discourse/public";
root = "${cfg.package}/share/discourse/public";
locations =
let
@ -889,7 +893,7 @@ in
"~ ^/uploads/" = proxy {
extraConfig = cache_1y + ''
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /run/discourse/public/=/downloads/;
proxy_set_header X-Accel-Mapping ${cfg.package}/share/discourse/public/=/downloads/;
# custom CSS
location ~ /stylesheet-cache/ {
@ -911,7 +915,7 @@ in
"~ ^/admin/backups/" = proxy {
extraConfig = ''
proxy_set_header X-Sendfile-Type X-Accel-Redirect;
proxy_set_header X-Accel-Mapping /run/discourse/public/=/downloads/;
proxy_set_header X-Accel-Mapping ${cfg.package}/share/discourse/public/=/downloads/;
'';
};
"~ ^/(svg-sprite/|letter_avatar/|letter_avatar_proxy/|user_avatar|highlight-js|stylesheets|theme-javascripts|favicon/proxied|service-worker)" = proxy {
@ -938,7 +942,7 @@ in
};
"/downloads/".extraConfig = ''
internal;
alias /run/discourse/public/;
alias ${cfg.package}/share/discourse/public/;
'';
};
};

View File

@ -297,7 +297,7 @@ services.discourse = {
the script:
<programlisting language="bash">
./update.py update-plugins
</programlisting>.
</programlisting>
</para>
<para>

View File

@ -58,6 +58,10 @@ let
nativeBuildInputs = [ which pkg-config python ]
++ optionals stdenv.isDarwin [ xcbuild ];
outputs = [ "out" "libv8" ];
setOutputFlags = false;
moveToDev = false;
configureFlags = let
isCross = stdenv.hostPlatform != stdenv.buildPlatform;
inherit (stdenv.hostPlatform) gcc isAarch32;
@ -130,6 +134,35 @@ let
# install the missing headers for node-gyp
cp -r ${concatStringsSep " " copyLibHeaders} $out/include/node
# assemble a static v8 library and put it in the 'libv8' output
mkdir -p $libv8/lib
pushd out/Release/obj.target
find . -path "./torque_*/**/*.o" -or -path "./v8*/**/*.o" | sort -u >files
${if stdenv.buildPlatform.isGnu then ''
ar -cqs $libv8/lib/libv8.a @files
'' else ''
cat files | while read -r file; do
ar -cqS $libv8/lib/libv8.a $file
done
''}
popd
# copy v8 headers
cp -r deps/v8/include $libv8/
# create a pkgconfig file for v8
major=$(grep V8_MAJOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3)
minor=$(grep V8_MINOR_VERSION deps/v8/include/v8-version.h | cut -d ' ' -f 3)
patch=$(grep V8_PATCH_LEVEL deps/v8/include/v8-version.h | cut -d ' ' -f 3)
mkdir -p $libv8/lib/pkgconfig
cat > $libv8/lib/pkgconfig/v8.pc << EOF
Name: v8
Description: V8 JavaScript Engine
Version: $major.$minor.$patch
Libs: -L$libv8/lib -lv8 -pthread -licui18n
Cflags: -I$libv8/include
EOF
'' + optionalString (stdenv.isDarwin && enableNpm) ''
sed -i 's/raise.*No Xcode or CLT version detected.*/version = "7.0.0"/' $out/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py
'';

View File

@ -1,8 +1,8 @@
diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb
index 380a63e987..b2ce7fa982 100644
index e59a6fbc05..c773a1356e 100644
--- a/lib/plugin/instance.rb
+++ b/lib/plugin/instance.rb
@@ -403,7 +403,7 @@ class Plugin::Instance
@@ -447,7 +447,7 @@ class Plugin::Instance
end
def auto_generated_path

View File

@ -1,22 +1,22 @@
{ stdenv, pkgs, makeWrapper, runCommand, lib, writeShellScript
, fetchFromGitHub, bundlerEnv, callPackage
, ruby, replace, gzip, gnutar, git, cacert, util-linux, gawk
, ruby, replace, gzip, gnutar, git, cacert, util-linux, gawk, nettools
, imagemagick, optipng, pngquant, libjpeg, jpegoptim, gifsicle, jhead
, libpsl, redis, postgresql, which, brotli, procps, rsync
, nodePackages, v8
, libpsl, redis, postgresql, which, brotli, procps, rsync, icu
, nodePackages, nodejs-16_x
, plugins ? []
}@args:
let
version = "2.7.9";
version = "2.8.0.beta9";
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse";
rev = "v${version}";
sha256 = "sha256-SOERjFbG4l/tUfOl51XEW0nVbza3L4adjiPhz4Hj0YU=";
sha256 = "sha256-cTedMbf0N50ysRQqA9Fm1WQmI5J5hsqDSi2JZIa49jg=";
};
runtimeDeps = [
@ -33,6 +33,7 @@ let
procps # For ps and kill
util-linux # For renice
gawk
nettools # For hostname
# Image optimization
imagemagick
@ -110,16 +111,21 @@ let
gems = import ./rubyEnv/gemset.nix;
in
gems // {
mini_racer = gems.mini_racer // {
buildInputs = [ icu ];
dontBuild = false;
NIX_LDFLAGS = "-licui18n";
};
libv8-node =
let
noopScript = writeShellScript "noop" "exit 0";
linkFiles = writeShellScript "link-files" ''
cd ../..
mkdir -p vendor/v8/out.gn/libv8/obj/
ln -s "${v8}/lib/libv8.a" vendor/v8/out.gn/libv8/obj/libv8_monolith.a
mkdir -p vendor/v8/${stdenv.hostPlatform.system}/libv8/obj/
ln -s "${nodejs-16_x.libv8}/lib/libv8.a" vendor/v8/${stdenv.hostPlatform.system}/libv8/obj/libv8_monolith.a
ln -s ${v8}/include vendor/v8/include
ln -s ${nodejs-16_x.libv8}/include vendor/v8/include
mkdir -p ext/libv8-node
echo '--- !ruby/object:Libv8::Node::Location::Vendor {}' >ext/libv8-node/.location.yml
@ -155,13 +161,9 @@ let
pname = "discourse-assets";
inherit version src;
nativeBuildInputs = [
rubyEnv.wrappedRuby
nativeBuildInputs = runtimeDeps ++ [
postgresql
redis
which
brotli
procps
nodePackages.uglify-js
nodePackages.terser
];
@ -255,10 +257,6 @@ let
# one constructed by bundlerEnv
./plugin_gem_api_version.patch
# Use mv instead of rename, since rename doesn't work across
# device boundaries
./use_mv_instead_of_rename.patch
# Change the path to the auto generated plugin assets, which
# defaults to the plugin's directory and isn't writable at the
# time of asset generation
@ -266,11 +264,6 @@ let
# Make sure the notification email setting applies
./notification_email.patch
# Change the path to the public directory reported by Discourse
# to its real path instead of the symlink in the store, since
# the store path won't be matched by any nginx rules
./public_dir_path.patch
];
postPatch = ''

View File

@ -0,0 +1,4 @@
Run the nixpkgs/pkgs/servers/web-apps/discourse/update.py script to
update plugins! See the Plugins section of the Discourse chapter in
the NixOS manual (https://nixos.org/manual/nixos/unstable/index.html#module-services-discourse)
for more info.

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-assign";
rev = "5124ba0f67e26a075f0a0fc8993273f1211d1c28";
sha256 = "1zd2irp5siza0vd5rlwzmjfvcdfw785988jc526xc741flazk1lr";
rev = "91d0712b0440b6bb0c2fedbf6c31191cdeb991fe";
sha256 = "sha256-ATWLu0vJZFquRcAUpFKaU8mqjjVOv3PziAsHR3aemWk=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-docs";

View File

@ -8,14 +8,14 @@ GEM
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
concurrent-ruby (1.1.9)
i18n (1.8.10)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
minitest (5.14.4)
rrule (0.4.2)
activesupport (>= 4.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)
zeitwerk (2.5.1)
PLATFORMS
ruby

View File

@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-calendar";
rev = "2f76cdd3064735d484be1df77f43100aca21aea6";
sha256 = "1skpc8p5br1jkii1rksha1q95ias6xxyvi5bnli3q41w7fz1h5j2";
rev = "fbc617a5fa9f3a22bcc72bc2b32ea3cbdf6087c5";
sha256 = "sha256-qBtq8IvxdKYIFNL9DwdRqZceMMO/qgd6jTr3kk3so3Y=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-calendar";

View File

@ -26,10 +26,10 @@
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "0g2fnag935zn2ggm5cn6k4s4xvv53v2givj1j90szmvavlpya96a";
sha256 = "0vdd1kii40qhbr9n8qx71k2gskq6rkl8ygy8hw5hfj8bb5a364xf";
type = "gem";
};
version = "1.8.10";
version = "1.8.11";
};
minitest = {
groups = ["default"];
@ -68,9 +68,9 @@
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "1746czsjarixq0x05f7p3hpzi38ldg6wxnxxw74kbjzh1sdjgmpl";
sha256 = "18l4r6layck0d80ydc692mv1lxak5xbf6w2paj1x7m2ggbggzxgj";
type = "gem";
};
version = "2.4.2";
version = "2.5.1";
};
}

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-chat-integration";
rev = "8ade892b387f0ce843d5e78ef4a271b0d35847ff";
sha256 = "1qn1bm09i9gzmh74ws32zgc89hrqzyhmh63qvmv0h00r52rmgxvx";
rev = "ae0389ca89f26401a6c4cffaaae6adcf14af0e15";
sha256 = "sha256-wT9S2mMz2MOpWpYv/FrHYhZibStRIGC4P2Vrqs04bkA=";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-chat-integration";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-checklist";
rev = "48855d81b7c3a3274f7f78a64312125c344d92d1";
sha256 = "0139v5wpyglfzvd07ka6gic1ssfysisgfiq09dsbjy519gnc9kjw";
rev = "d8012abd3d6dccb72eec83e6a96ef4809dcad681";
sha256 = "1ngjql65939c571gyaqj8ydcxy5kkril2qlkxqf579vvwzpvxw13";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-checklist";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-data-explorer";
rev = "23287ece952cb45203819e7b470ebc194c58cb13";
sha256 = "1vc2072r72fkvcfpy6vpn9x4gl9lpjk29pnj8095xs22im8j5in1";
rev = "3ce778ec6d96a300a06ffe0581f4681fbed8df7f";
sha256 = "1555k1anrijfbm0qfraby3ivh6h76177d541nxhnarj85mjx0hjb";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-data-explorer";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-docs";
rev = "72cdd8d415ae3f797c0d5e2c857370714a42c54a";
sha256 = "07hvw8lpg8873vhwh8rrbml3s5hq606b7sw93r2xv38gxfhmx5lq";
rev = "d3eee7008b7a703774331808e302e36f2f8b4eae";
sha256 = "1p3aqfpv207pvlbis43znwgw56yqsn41320yaw1gdcaakf5s2rsx";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-docs";

View File

@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-github";
rev = "9aaf4350968fb758f9bff3588f78e3ad24ddb4b0";
sha256 = "0nmpkh1rr0jv68a655f5610v2mn09xriiqv049a0gklap2lgv7p8";
rev = "8cd8c0703991c16cb2fa8cb1fd22a9c3849c7ae2";
sha256 = "17ga31a10sm3fqjpf40mz7fk62vynyng2a243pia9fjdq9py8slx";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-github";

View File

@ -2,6 +2,9 @@
source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem 'pyu-ruby-sasl', '0.0.3.3', require: false
gem 'rubyntlm', '0.3.4', require: false
gem 'net-ldap', '0.14.0'

View File

@ -1,7 +1,7 @@
GEM
remote: https://rubygems.org/
specs:
hashie (4.1.0)
hashie (5.0.0)
net-ldap (0.14.0)
omniauth (1.9.1)
hashie (>= 3.4.6)
@ -16,7 +16,7 @@ GEM
rubyntlm (0.3.4)
PLATFORMS
x86_64-linux
ruby
DEPENDENCIES
net-ldap (= 0.14.0)
@ -25,4 +25,4 @@ DEPENDENCIES
rubyntlm (= 0.3.4)
BUNDLED WITH
2.2.20
2.2.24

View File

@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "jonmbake";
repo = "discourse-ldap-auth";
rev = "eca02c560f2f2bf42feeb1923bc17e074f16b891";
sha256 = "sha256-HLNoDvvxkBMvqP6WbRrJY0CYnK92W77nzSpuwgl0VPA=";
rev = "1c10221836393c3cfac470a7b08de6f31150c802";
sha256 = "sha256-IiAl3OTADXSUnL+OKKHJY9Xqd4zCNJ2wOrgTN3nm5Yw=";
};
meta = with lib; {
homepage = "https://github.com/jonmbake/discourse-ldap-auth";

View File

@ -4,10 +4,10 @@
platforms = [];
source = {
remotes = ["https://rubygems.org"];
sha256 = "02bsx12ihl78x0vdm37byp78jjw2ff6035y7rrmbd90qxjwxr43q";
sha256 = "1nh3arcrbz1rc1cr59qm53sdhqm137b258y8rcb4cvd3y98lwv4x";
type = "gem";
};
version = "4.1.0";
version = "5.0.0";
};
net-ldap = {
groups = ["default"];

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-math";
rev = "d7d0180352dd5a7dcb76c0817bfbb08c2a0f08c7";
sha256 = "0y72impvnq965ibbfc9877hr78fxkrwav1xmgyy3r9w87952vcwa";
rev = "cacbd04bb239db3c772ff5a37c19fe39d127ff3d";
sha256 = "1bhs7wslb4rdf2b6h6klw1mpjf9pjpfpf2zg2mj8vg0acyaqvv9d";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-math";

View File

@ -6,8 +6,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-openid-connect";
rev = "615038bd65f4fbe4dfdf8444b2f5eb06986b80b8";
sha256 = "n8feZkP80iNc+BzTPyKD7kEgFSIkk091eJYuqonN/NU=";
rev = "0e1511fcec2bbb26ef08e453920e955d4140df42";
sha256 = "02knx3z0ycz83cdarld2hmmpl6f9nkd2snp0qsbk9mjvbfvpfkni";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-openid-connect";

View File

@ -2,7 +2,7 @@
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# gem "rails"
gem 'prometheus_exporter', '0.5.0'
gem 'prometheus_exporter', File.read(File.expand_path("../prometheus_exporter_version", __FILE__)).strip

View File

@ -10,4 +10,4 @@ DEPENDENCIES
prometheus_exporter (= 0.5.0)
BUNDLED WITH
2.1.4
2.2.24

View File

@ -6,8 +6,8 @@
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-prometheus";
rev = "46260710e8770344af438f86b47409d864a1c499";
sha256 = "0nmpi0nysp59x4hyn1c3niypvxw1jkz86acb6m8acacw0c6682k2";
rev = "08138ae4f89da76dd577781a2116b2ab66f8f547";
sha256 = "1x4awgx9fj0a6drsix3mi39ynj56rca3km0fz2xb3g6vxgc7d2z1";
};
patches = [

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-solved";
rev = "55cb184f7ef2954326561cc44fc8134798b8a9e0";
sha256 = "0pv5i216zn0v8xfwlndvhvr06vkmxaynj8xjfnc5amy1sp6k76w7";
rev = "40277e50d43e4bdaab99efab44f59f6e33d74740";
sha256 = "02n266swdslws8r26xf99l3ghpqd3dryd0qfp7kiqk3ksy8hh5n2";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-solved";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-spoiler-alert";
rev = "0b93227ea8e2c72afe72029382081ebff89c3638";
sha256 = "0x0dxb41ss15sv5ph7z7q55ayf8a7r22bgkmr17924mny5440b5a";
rev = "790380d9d321f9368c7a16d8ed87718fc6047bf2";
sha256 = "079w4x2wlbsx164wv0zb373r8552wb5fvrb9pqzmrfvy0ybwf328";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-spoiler-alert";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-voting";
rev = "fc4d23174eba1a57ddcba93eaf4a4e75d469d4a4";
sha256 = "07mj667qn387kaafg475f36pgnannsrb2bdqi0zj487av43252qb";
rev = "36a41c2969c1ddfd8980e3f766b730b849726a08";
sha256 = "0ns2i8liwpd29kbn44wzx9yb0jfpyz70h0hmrs71hz6fdalzm4ph";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-voting";

View File

@ -5,8 +5,8 @@ mkDiscoursePlugin {
src = fetchFromGitHub {
owner = "discourse";
repo = "discourse-yearly-review";
rev = "cb040562f6af3163d70e8932867b530c6640ab9a";
sha256 = "07h6nq4bafs27ly2f5chkn5vb1wdy909qffwkgp5k1fanhbqvhvs";
rev = "683327574ea1a67c9c4182c887d6ba85171ca02b";
sha256 = "0y0hvb2ir9254ilpf7mnbn9xvv9anyqj4qwh97cw7jly7n2mga4m";
};
meta = with lib; {
homepage = "https://github.com/discourse/discourse-yearly-review";

View File

@ -1,39 +0,0 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl ruby.devEnv git sqlite libpcap postgresql libxml2 libxslt pkg-config bundix gnumake
# src https://nixos.wiki/wiki/Packaging/Ruby
# This script should be ran afte rupdating a plugin that has a gemset.nix
# Usage: ./up-plugin.sh <plugin-id>
# NOTE: Script must be ran directly as ./up-plugin, otherwise the nix-shell won't work
set -exuo pipefail
PLUGIN="$1"
SELF="$(dirname "$(readlink -f "$0")")"
PL_DIR="$SELF/$PLUGIN"
TOP="$SELF/../../../../.."
TMP=$(mktemp -d)
pushd "$TMP"
if cat "$PL_DIR/default.nix" | grep gemdir >/dev/null; then
nix-build -A discourse.plugins.$PLUGIN.src "$TOP"
if [ -e result/Gemfile ]; then
cp result/Gemfile Gemfile
if [ -e result/Gemfile.lock ]; then
cp result/Gemfile.lock Gemfile.lock
fi
else
echo '# frozen_string_literal: true
source "https://rubygems.org"' > Gemfile
cat result/plugin.rb | grep "^gem" >> Gemfile
fi
if [ ! -e Gemfile.lock ]; then
bundle install
fi
bundix
cp Gemfile Gemfile.lock gemset.nix "$PL_DIR"
fi

View File

@ -1,13 +0,0 @@
diff --git a/lib/file_store/local_store.rb b/lib/file_store/local_store.rb
index 25649532c0..614e062dc1 100644
--- a/lib/file_store/local_store.rb
+++ b/lib/file_store/local_store.rb
@@ -88,7 +88,7 @@ module FileStore
end
def public_dir
- File.join(Rails.root, "public")
+ "/run/discourse/public"
end
def tombstone_dir

View File

@ -18,13 +18,14 @@ else
# this allows us to include the bits of rails we use without pieces we do not.
#
# To issue a rails update bump the version number here
gem 'actionmailer', '6.1.3.2'
gem 'actionpack', '6.1.3.2'
gem 'actionview', '6.1.3.2'
gem 'activemodel', '6.1.3.2'
gem 'activerecord', '6.1.3.2'
gem 'activesupport', '6.1.3.2'
gem 'railties', '6.1.3.2'
rails_version = '6.1.4.1'
gem 'actionmailer', rails_version
gem 'actionpack', rails_version
gem 'actionview', rails_version
gem 'activemodel', rails_version
gem 'activerecord', rails_version
gem 'activesupport', rails_version
gem 'railties', rails_version
gem 'sprockets-rails'
end
@ -60,8 +61,6 @@ gem 'redis-namespace'
# better maintained living fork
gem 'active_model_serializers', '~> 0.8.3'
gem 'onebox'
gem 'http_accept_language', require: false
# Ember related gems need to be pinned cause they control client side
@ -90,9 +89,7 @@ gem 'unf', require: false
gem 'email_reply_trimmer'
# Forked until https://github.com/toy/image_optim/pull/162 is merged
# https://github.com/discourse/image_optim
gem 'discourse_image_optim', require: 'image_optim'
gem 'image_optim'
gem 'multi_json'
gem 'mustache'
gem 'nokogiri'
@ -108,7 +105,10 @@ gem 'omniauth-oauth2', require: false
gem 'omniauth-google-oauth2'
gem 'oj'
# Pinning oj until https://github.com/ohler55/oj/issues/699 is resolved.
# Segfaults and stuck processes after upgrading.
gem 'oj', '3.13.2'
gem 'pg'
gem 'mini_sql'
gem 'pry-rails', require: false
@ -169,6 +169,8 @@ group :test, :development do
gem 'parallel_tests'
gem 'rswag-specs'
gem 'annotate'
end
group :development do
@ -177,8 +179,16 @@ group :development do
gem 'better_errors', platform: :mri, require: !!ENV['BETTER_ERRORS']
gem 'binding_of_caller'
gem 'yaml-lint'
gem 'annotate'
gem 'discourse_dev'
end
if ENV["ALLOW_DEV_POPULATE"] == "1"
gem 'discourse_dev_assets'
gem 'faker', "~> 2.16"
else
group :development do
gem 'discourse_dev_assets'
gem 'faker', "~> 2.16"
end
end
# this is an optional gem, it provides a high performance replacement
@ -205,6 +215,9 @@ gem 'gc_tracer', require: false, platform: :mri
# required for feed importing and embedding
gem 'ruby-readability', require: false
# rss gem is a bundled gem from Ruby 3 onwards
gem 'rss', require: false
gem 'stackprof', require: false, platform: :mri
gem 'memory_profiler', require: false, platform: :mri
@ -231,6 +244,8 @@ gem 'sshkey', require: false
gem 'rchardet', require: false
gem 'lz4-ruby', require: false, platform: :ruby
gem 'sanitize'
if ENV["IMPORT"] == "1"
gem 'mysql2'
gem 'redcarpet'

View File

@ -8,22 +8,22 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (6.1.3.2)
actionpack (= 6.1.3.2)
actionview (= 6.1.3.2)
activejob (= 6.1.3.2)
activesupport (= 6.1.3.2)
actionmailer (6.1.4.1)
actionpack (= 6.1.4.1)
actionview (= 6.1.4.1)
activejob (= 6.1.4.1)
activesupport (= 6.1.4.1)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.3.2)
actionview (= 6.1.3.2)
activesupport (= 6.1.3.2)
actionpack (6.1.4.1)
actionview (= 6.1.4.1)
activesupport (= 6.1.4.1)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.3.2)
activesupport (= 6.1.3.2)
actionview (6.1.4.1)
activesupport (= 6.1.4.1)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
@ -32,21 +32,21 @@ GEM
actionview (>= 6.0.a)
active_model_serializers (0.8.4)
activemodel (>= 3.0)
activejob (6.1.3.2)
activesupport (= 6.1.3.2)
activejob (6.1.4.1)
activesupport (= 6.1.4.1)
globalid (>= 0.3.6)
activemodel (6.1.3.2)
activesupport (= 6.1.3.2)
activerecord (6.1.3.2)
activemodel (= 6.1.3.2)
activesupport (= 6.1.3.2)
activesupport (6.1.3.2)
activemodel (6.1.4.1)
activesupport (= 6.1.4.1)
activerecord (6.1.4.1)
activemodel (= 6.1.4.1)
activesupport (= 6.1.4.1)
activesupport (6.1.4.1)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.7.0)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
annotate (3.1.1)
activerecord (>= 3.2, < 7.0)
@ -59,10 +59,10 @@ GEM
aws-partitions (~> 1, >= 1.239.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1.0)
aws-sdk-kms (1.42.0)
aws-sdk-kms (1.44.0)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.90.0)
aws-sdk-s3 (1.96.1)
aws-sdk-core (~> 3, >= 3.112.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.1)
@ -80,10 +80,10 @@ GEM
rack (>= 0.9.0)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
bootsnap (1.7.5)
bootsnap (1.9.3)
msgpack (~> 1.0)
builder (3.2.4)
bullet (6.1.4)
bullet (6.1.5)
activesupport (>= 3.0.0)
uniform_notifier (~> 1.11)
byebug (11.1.3)
@ -92,7 +92,7 @@ GEM
chunky_png (1.4.0)
coderay (1.1.3)
colored2 (3.1.2)
concurrent-ruby (1.1.8)
concurrent-ruby (1.1.9)
connection_pool (2.2.5)
cose (1.2.0)
cbor (~> 0.5.9)
@ -101,7 +101,7 @@ GEM
crack (0.4.5)
rexml
crass (1.0.6)
css_parser (1.9.0)
css_parser (1.10.0)
addressable
debug_inspector (1.1.0)
diff-lcs (1.4.4)
@ -114,15 +114,10 @@ GEM
jquery-rails (>= 1.0.17)
railties (>= 3.1)
discourse-ember-source (3.12.2.3)
discourse-fonts (0.0.8)
discourse_dev (0.2.1)
discourse-fonts (0.0.9)
discourse_dev_assets (0.0.3)
faker (~> 2.16)
discourse_image_optim (0.26.2)
exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0)
image_size (~> 1.5)
in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1)
literate_randomizer
docile (1.4.0)
ecma-re-validator (0.3.0)
regexp_parser (~> 2.0)
@ -134,30 +129,40 @@ GEM
sprockets (>= 3.3, < 4.1)
ember-source (2.18.2)
erubi (1.10.0)
excon (0.81.0)
excon (0.88.0)
execjs (2.8.1)
exifr (1.3.9)
fabrication (2.22.0)
faker (2.17.0)
faker (2.19.0)
i18n (>= 1.6, < 2)
fakeweb (1.3.0)
faraday (1.4.1)
faraday (1.8.0)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
multipart-post (>= 1.2, < 3)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.1.0)
fast_blank (1.0.0)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
fast_blank (1.0.1)
fast_xs (0.8.0)
fastimage (2.2.3)
ffi (1.15.0)
fastimage (2.2.5)
ffi (1.15.4)
fspath (3.1.2)
gc_tracer (1.5.1)
globalid (0.4.2)
activesupport (>= 4.2.0)
globalid (1.0.0)
activesupport (>= 5.0)
guess_html_encoding (0.0.11)
hana (1.3.7)
hashdiff (1.0.1)
@ -166,16 +171,23 @@ GEM
hkdf (0.3.0)
htmlentities (4.3.4)
http_accept_language (2.1.1)
i18n (1.8.10)
i18n (1.8.11)
concurrent-ruby (~> 1.0)
image_size (1.5.0)
image_optim (0.31.1)
exifr (~> 1.2, >= 1.2.2)
fspath (~> 3.0)
image_size (>= 1.5, < 4)
in_threads (~> 1.3)
progress (~> 3.0, >= 3.0.1)
image_size (3.0.1)
in_threads (1.5.4)
ipaddr (1.2.3)
jmespath (1.4.0)
jquery-rails (4.4.0)
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.5.1)
json (2.6.1)
json-schema (2.8.1)
addressable (>= 2.4)
json_schemer (0.2.18)
@ -183,12 +195,14 @@ GEM
hana (~> 1.3)
regexp_parser (~> 2.0)
uri_template (~> 0.7)
jwt (2.2.3)
kgio (2.11.3)
libv8-node (15.14.0.1)
listen (3.5.1)
jwt (2.3.0)
kgio (2.11.4)
libv8-node (16.10.0.0)
libv8-node (16.10.0.0-aarch64-linux)
listen (3.7.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
literate_randomizer (0.4.0)
lograge (0.11.2)
actionpack (>= 4)
activesupport (>= 4)
@ -197,53 +211,51 @@ GEM
logstash-event (1.2.02)
logstash-logger (0.26.1)
logstash-event (~> 1.2)
logster (2.9.6)
loofah (2.9.1)
logster (2.10.0)
loofah (2.12.0)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
lru_redux (1.1.0)
lz4-ruby (0.3.3)
maxminddb (0.1.22)
memory_profiler (1.0.0)
message_bus (3.3.5)
message_bus (3.3.6)
rack (>= 1.1.3)
method_source (1.0.0)
mini_mime (1.1.0)
mini_portile2 (2.5.3)
mini_racer (0.4.0)
libv8-node (~> 15.14.0.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
mini_racer (0.5.0)
libv8-node (~> 16.10.0.0)
mini_scheduler (0.13.0)
sidekiq (>= 4.2.3)
mini_sql (1.1.3)
mini_suffix (0.3.2)
ffi (~> 1.9)
minitest (5.14.4)
mocha (1.12.0)
mock_redis (0.28.0)
mocha (1.13.0)
mock_redis (0.29.0)
ruby2_keywords
msgpack (1.4.2)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
mustache (1.1.1)
nio4r (2.5.7)
nokogiri (1.11.7)
mini_portile2 (~> 2.5.0)
nio4r (2.5.8)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
nokogumbo (2.0.5)
nokogiri (~> 1.8, >= 1.8.4)
oauth (0.5.6)
oauth (0.5.8)
oauth2 (1.4.7)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
oj (3.11.5)
oj (3.13.2)
omniauth (1.9.1)
hashie (>= 3.4.6)
rack (>= 1.6.2, < 3)
omniauth-facebook (8.0.0)
omniauth-facebook (9.0.0)
omniauth-oauth2 (~> 1.2)
omniauth-github (1.4.0)
omniauth (~> 1.5)
@ -256,27 +268,21 @@ GEM
omniauth-oauth (1.2.0)
oauth
omniauth (>= 1.0, < 3)
omniauth-oauth2 (1.7.1)
omniauth-oauth2 (1.7.2)
oauth2 (~> 1.4)
omniauth (>= 1.9, < 3)
omniauth-twitter (1.4.0)
omniauth-oauth (~> 1.1)
rack
onebox (2.2.17)
addressable (~> 2.7.0)
htmlentities (~> 4.3)
multi_json (~> 1.11)
mustache
nokogiri (~> 1.7)
sanitize
openssl (2.2.0)
openssl (2.2.1)
ipaddr
openssl-signature_algorithm (1.1.1)
openssl (~> 2.0)
optimist (3.0.1)
parallel (1.20.1)
parallel_tests (3.7.0)
parallel (1.21.0)
parallel_tests (3.7.3)
parallel
parser (3.0.1.1)
parser (3.0.3.1)
ast (~> 2.4.1)
pg (1.2.3)
progress (3.6.0)
@ -289,12 +295,12 @@ GEM
pry-rails (0.3.9)
pry (>= 0.10.4)
public_suffix (4.0.6)
puma (5.3.1)
puma (5.5.2)
nio4r (~> 2.0)
r2 (0.2.7)
racc (1.5.2)
racc (1.6.0)
rack (2.2.3)
rack-mini-profiler (2.3.2)
rack-mini-profiler (2.3.3)
rack (>= 1.2.0)
rack-protection (2.1.0)
rack
@ -303,24 +309,24 @@ GEM
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.3.0)
rails-html-sanitizer (1.4.2)
loofah (~> 2.3)
rails_failover (0.7.3)
activerecord (~> 6.0)
concurrent-ruby
railties (~> 6.0)
rails_multisite (3.0.0)
rails_multisite (4.0.0)
activerecord (> 5.0, < 7)
railties (> 5.0, < 7)
railties (6.1.3.2)
actionpack (= 6.1.3.2)
activesupport (= 6.1.3.2)
railties (6.1.4.1)
actionpack (= 6.1.4.1)
activesupport (= 6.1.4.1)
method_source
rake (>= 0.8.7)
rake (>= 0.13)
thor (~> 1.0)
rainbow (3.0.0)
raindrops (0.19.1)
rake (13.0.3)
raindrops (0.19.2)
rake (13.0.6)
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
@ -329,7 +335,7 @@ GEM
msgpack (>= 0.4.3)
optimist (>= 3.0.0)
rchardet (1.8.0)
redis (4.2.5)
redis (4.5.1)
redis-namespace (1.8.1)
redis (>= 3.0.4)
regexp_parser (2.1.1)
@ -338,10 +344,10 @@ GEM
rexml (3.2.5)
rinku (2.0.6)
rotp (6.2.0)
rqrcode (2.0.0)
rqrcode (2.1.0)
chunky_png (~> 1.0)
rqrcode_core (~> 1.0)
rqrcode_core (1.0.0)
rqrcode_core (1.2.0)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
@ -357,7 +363,7 @@ GEM
rspec-mocks (3.10.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0)
rspec-rails (5.0.1)
rspec-rails (5.0.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
railties (>= 5.2)
@ -365,40 +371,40 @@ GEM
rspec-expectations (~> 3.10)
rspec-mocks (~> 3.10)
rspec-support (~> 3.10)
rspec-support (3.10.2)
rspec-support (3.10.3)
rss (0.2.9)
rexml
rswag-specs (2.4.0)
activesupport (>= 3.1, < 7.0)
json-schema (~> 2.2)
railties (>= 3.1, < 7.0)
rtlit (0.0.5)
rubocop (1.14.0)
rubocop (1.23.0)
parallel (~> 1.10)
parser (>= 3.0.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.5.0, < 2.0)
rubocop-ast (>= 1.12.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.5.0)
rubocop-ast (1.13.0)
parser (>= 3.0.1.1)
rubocop-discourse (2.4.1)
rubocop-discourse (2.4.2)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-rspec (2.3.0)
rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
rubocop-rspec (2.6.0)
rubocop (~> 1.19)
ruby-prof (1.4.3)
ruby-progressbar (1.11.0)
ruby-readability (0.7.0)
guess_html_encoding (>= 0.0.4)
nokogiri (>= 1.6.0)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
sanitize (5.2.3)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
sanitize (6.0.0)
crass (~> 1.0.2)
nokogiri (>= 1.8.0)
nokogumbo (~> 2.0)
nokogiri (>= 1.12.0)
sassc (2.0.1)
ffi (~> 1.9)
rake
@ -411,9 +417,9 @@ GEM
seed-fu (2.3.9)
activerecord (>= 3.1)
activesupport (>= 3.1)
shoulda-matchers (4.5.1)
activesupport (>= 4.2.0)
sidekiq (6.2.1)
shoulda-matchers (5.0.0)
activesupport (>= 5.2.0)
sidekiq (6.3.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
@ -426,13 +432,13 @@ GEM
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (3.2.2)
actionpack (>= 4.0)
activesupport (>= 4.0)
sprockets-rails (3.4.1)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets (>= 3.0.0)
sshkey (2.0.0)
stackprof (0.2.17)
test-prof (1.0.5)
test-prof (1.0.7)
thor (1.1.0)
tilt (2.0.10)
tzinfo (2.0.4)
@ -441,15 +447,15 @@ GEM
execjs (>= 0.3.0, < 3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.7)
unicode-display_width (2.0.0)
unf_ext (0.0.8)
unicode-display_width (2.1.0)
unicorn (6.0.0)
kgio (~> 2.6)
raindrops (~> 0.7)
uniform_notifier (1.14.2)
uri_template (0.7.0)
webmock (3.12.2)
addressable (>= 2.3.6)
webmock (3.14.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
webpush (1.1.0)
@ -457,20 +463,21 @@ GEM
jwt (~> 2.0)
xorcist (1.1.2)
yaml-lint (0.0.10)
zeitwerk (2.4.2)
zeitwerk (2.5.1)
PLATFORMS
aarch64-linux
ruby
DEPENDENCIES
actionmailer (= 6.1.3.2)
actionpack (= 6.1.3.2)
actionview (= 6.1.3.2)
actionmailer (= 6.1.4.1)
actionpack (= 6.1.4.1)
actionview (= 6.1.4.1)
actionview_precompiler
active_model_serializers (~> 0.8.3)
activemodel (= 6.1.3.2)
activerecord (= 6.1.3.2)
activesupport (= 6.1.3.2)
activemodel (= 6.1.4.1)
activerecord (= 6.1.4.1)
activesupport (= 6.1.4.1)
addressable
annotate
aws-sdk-s3
@ -491,13 +498,13 @@ DEPENDENCIES
discourse-ember-rails (= 0.18.6)
discourse-ember-source (~> 3.12.2)
discourse-fonts
discourse_dev
discourse_image_optim
discourse_dev_assets
email_reply_trimmer
ember-handlebars-template (= 0.8.0)
excon
execjs
fabrication
faker (~> 2.16)
fakeweb
fast_blank
fast_xs
@ -506,6 +513,7 @@ DEPENDENCIES
highline
htmlentities
http_accept_language
image_optim
json
json_schemer
listen
@ -531,14 +539,13 @@ DEPENDENCIES
multi_json
mustache
nokogiri
oj
oj (= 3.13.2)
omniauth
omniauth-facebook
omniauth-github
omniauth-google-oauth2
omniauth-oauth2
omniauth-twitter
onebox
parallel_tests
pg
pry-byebug
@ -550,7 +557,7 @@ DEPENDENCIES
rack-protection
rails_failover
rails_multisite
railties (= 6.1.3.2)
railties (= 6.1.4.1)
rake
rb-fsevent
rbtrace
@ -563,12 +570,14 @@ DEPENDENCIES
rspec
rspec-html-matchers
rspec-rails
rss
rswag-specs
rtlit
rubocop-discourse
ruby-prof
ruby-readability
rubyzip
sanitize
sassc (= 2.0.1)
sassc-rails
seed-fu
@ -590,4 +599,4 @@ DEPENDENCIES
yaml-lint
BUNDLED WITH
2.2.24
2.2.26

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,6 @@
#!/usr/bin/env nix-shell
#! nix-shell -i python3 -p bundix bundler nix-update nix-universal-prefetch python3 python3Packages.requests python3Packages.click python3Packages.click-log
from __future__ import annotations
import click
import click_log
@ -13,16 +14,70 @@ import stat
import json
import requests
import textwrap
from functools import total_ordering
from distutils.version import LooseVersion
from itertools import zip_longest
from pathlib import Path
from typing import Iterable
from typing import Union, Iterable
logger = logging.getLogger(__name__)
@total_ordering
class DiscourseVersion:
"""Represents a Discourse style version number and git tag.
This takes either a tag or version string as input and
extrapolates the other. Sorting is implemented to work as expected
in regard to A.B.C.betaD version numbers - 2.0.0.beta1 is
considered lower than 2.0.0.
"""
tag: str = ""
version: str = ""
split_version: Iterable[Union[None, int, str]] = []
def __init__(self, version: str):
"""Take either a tag or version number, calculate the other."""
if version.startswith('v'):
self.tag = version
self.version = version.lstrip('v')
else:
self.tag = 'v' + version
self.version = version
self.split_version = LooseVersion(self.version).version
def __eq__(self, other: DiscourseVersion):
"""Versions are equal when their individual parts are."""
return self.split_version == other.split_version
def __gt__(self, other: DiscourseVersion):
"""Check if this version is greater than the other.
Goes through the parts of the version numbers from most to
least significant, only continuing on to the next if the
numbers are equal and no decision can be made. If one version
ends in 'betaX' and the other doesn't, all else being equal,
the one without 'betaX' is considered greater, since it's the
release version.
"""
for (this_ver, other_ver) in zip_longest(self.split_version, other.split_version):
if this_ver == other_ver:
continue
if type(this_ver) is int and type(other_ver) is int:
return this_ver > other_ver
elif 'beta' in [this_ver, other_ver]:
# release version (None) is greater than beta
return this_ver is None
else:
return False
class DiscourseRepo:
version_regex = re.compile(r'^v\d+\.\d+\.\d+$')
version_regex = re.compile(r'^v\d+\.\d+\.\d+(\.beta\d+)?$')
_latest_commit_sha = None
def __init__(self, owner: str = 'discourse', repo: str = 'discourse'):
@ -30,15 +85,14 @@ class DiscourseRepo:
self.repo = repo
@property
def tags(self) -> Iterable[str]:
def versions(self) -> Iterable[str]:
r = requests.get(f'https://api.github.com/repos/{self.owner}/{self.repo}/git/refs/tags').json()
tags = [x['ref'].replace('refs/tags/', '') for x in r]
# filter out versions not matching version_regex
versions = list(filter(self.version_regex.match, tags))
# sort, but ignore v for sorting comparisons
versions.sort(key=lambda x: LooseVersion(x.replace('v', '')), reverse=True)
versions = filter(self.version_regex.match, tags)
versions = [DiscourseVersion(x) for x in versions]
versions.sort(reverse=True)
return versions
@property
@ -50,24 +104,15 @@ class DiscourseRepo:
return self._latest_commit_sha
@staticmethod
def rev2version(tag: str) -> str:
"""
normalize a tag to a version number.
This obviously isn't very smart if we don't pass something that looks like a tag
:param tag: the tag to normalize
:return: a normalized version number
"""
# strip v prefix
return re.sub(r'^v', '', tag)
def get_file(self, filepath, rev):
"""returns file contents at a given rev :param filepath: the path to
the file, relative to the repo root :param rev: the rev to
fetch at :return:
"""
return requests.get(f'https://raw.githubusercontent.com/{self.owner}/{self.repo}/{rev}/{filepath}').text
r = requests.get(f'https://raw.githubusercontent.com/{self.owner}/{self.repo}/{rev}/{filepath}')
r.raise_for_status()
return r.text
def _call_nix_update(pkg, version):
@ -89,13 +134,13 @@ def _get_current_package_version(pkg: str):
return _nix_eval(f'{pkg}.version')
def _diff_file(filepath: str, old_version: str, new_version: str):
def _diff_file(filepath: str, old_version: DiscourseVersion, new_version: DiscourseVersion):
repo = DiscourseRepo()
current_dir = Path(__file__).parent
old = repo.get_file(filepath, 'v' + old_version)
new = repo.get_file(filepath, 'v' + new_version)
old = repo.get_file(filepath, old_version.tag)
new = repo.get_file(filepath, new_version.tag)
if old == new:
click.secho(f'{filepath} is unchanged', fg='green')
@ -111,7 +156,7 @@ def _diff_file(filepath: str, old_version: str, new_version: str):
text=True
)
click.secho(f'Diff for {filepath} ({old_version} -> {new_version}):', fg='bright_blue', bold=True)
click.secho(f'Diff for {filepath} ({old_version.version} -> {new_version.version}):', fg='bright_blue', bold=True)
click.echo(diff_proc.stdout + '\n')
return
@ -153,10 +198,10 @@ def print_diffs(rev, reverse):
"""
if rev == 'latest':
repo = DiscourseRepo()
rev = repo.tags[0]
rev = repo.versions[0].tag
old_version = _get_current_package_version('discourse')
new_version = DiscourseRepo.rev2version(rev)
old_version = DiscourseVersion(_get_current_package_version('discourse'))
new_version = DiscourseVersion(rev)
if reverse:
old_version, new_version = new_version, old_version
@ -170,30 +215,32 @@ def print_diffs(rev, reverse):
def update(rev):
"""Update gem files and version.
REV should be the git rev to update to ('vX.Y.Z') or 'latest';
defaults to 'latest'.
REV should be the git rev to update to ('vX.Y.Z[.betaA]') or
'latest'; defaults to 'latest'.
"""
repo = DiscourseRepo()
if rev == 'latest':
rev = repo.tags[0]
logger.debug(f"Using rev {rev}")
version = repo.versions[0]
else:
version = DiscourseVersion(rev)
version = repo.rev2version(rev)
logger.debug(f"Using version {version}")
logger.debug(f"Using rev {version.tag}")
logger.debug(f"Using version {version.version}")
rubyenv_dir = Path(__file__).parent / "rubyEnv"
for fn in ['Gemfile.lock', 'Gemfile']:
with open(rubyenv_dir / fn, 'w') as f:
f.write(repo.get_file(fn, rev))
f.write(repo.get_file(fn, version.tag))
subprocess.check_output(['bundle', 'lock'], cwd=rubyenv_dir)
_remove_platforms(rubyenv_dir)
subprocess.check_output(['bundix'], cwd=rubyenv_dir)
_call_nix_update('discourse', repo.rev2version(rev))
_call_nix_update('discourse', version.version)
@cli.command()
def update_plugins():
@ -212,9 +259,8 @@ def update_plugins():
{'name': 'discourse-ldap-auth', 'owner': 'jonmbake'},
{'name': 'discourse-math'},
{'name': 'discourse-migratepassword', 'owner': 'discoursehosting'},
# We can't update this automatically at the moment because the plugin.rb
# tries to load a version number which breaks bundler called by this script.
# {'name': 'discourse-prometheus'},
{'name': 'discourse-prometheus'},
{'name': 'discourse-openid-connect'},
{'name': 'discourse-saved-searches'},
{'name': 'discourse-solved'},
{'name': 'discourse-spoiler-alert'},
@ -230,13 +276,34 @@ def update_plugins():
repo = DiscourseRepo(owner=owner, repo=repo_name)
# implement the plugin pinning algorithm laid out here:
# https://meta.discourse.org/t/pinning-plugin-and-theme-versions-for-older-discourse-installs/156971
# this makes sure we don't upgrade plugins to revisions that
# are incompatible with the packaged Discourse version
try:
compatibility_spec = repo.get_file('.discourse-compatibility', repo.latest_commit_sha)
versions = [(DiscourseVersion(discourse_version), plugin_rev.strip(' '))
for [discourse_version, plugin_rev]
in [line.split(':')
for line
in compatibility_spec.splitlines()]]
discourse_version = DiscourseVersion(_get_current_package_version('discourse'))
versions = list(filter(lambda ver: ver[0] >= discourse_version, versions))
if versions == []:
rev = repo.latest_commit_sha
else:
rev = versions[0][1]
print(rev)
except requests.exceptions.HTTPError:
rev = repo.latest_commit_sha
filename = _nix_eval(f'builtins.unsafeGetAttrPos "src" discourse.plugins.{name}')
if filename is None:
filename = Path(__file__).parent / 'plugins' / name / 'default.nix'
filename.parent.mkdir()
has_ruby_deps = False
for line in repo.get_file('plugin.rb', repo.latest_commit_sha).splitlines():
for line in repo.get_file('plugin.rb', rev).splitlines():
if 'gem ' in line:
has_ruby_deps = True
break
@ -278,7 +345,7 @@ def update_plugins():
prev_commit_sha = _nix_eval(f'discourse.plugins.{name}.src.rev')
if prev_commit_sha == repo.latest_commit_sha:
if prev_commit_sha == rev:
click.echo(f'Plugin {name} is already at the latest revision')
continue
@ -287,14 +354,14 @@ def update_plugins():
'nix-universal-prefetch', fetcher,
'--owner', owner,
'--repo', repo_name,
'--rev', repo.latest_commit_sha,
'--rev', rev,
], text=True).strip("\n")
click.echo(f"Update {name}, {prev_commit_sha} -> {repo.latest_commit_sha} in {filename}")
click.echo(f"Update {name}, {prev_commit_sha} -> {rev} in {filename}")
with open(filename, 'r+') as f:
content = f.read()
content = content.replace(prev_commit_sha, repo.latest_commit_sha)
content = content.replace(prev_commit_sha, rev)
content = content.replace(prev_hash, new_hash)
f.seek(0)
f.write(content)
@ -302,11 +369,19 @@ def update_plugins():
rubyenv_dir = Path(filename).parent
gemfile = rubyenv_dir / "Gemfile"
version_file_regex = re.compile(r'.*File\.expand_path\("\.\./(.*)", __FILE__\)')
gemfile_text = ''
for line in repo.get_file('plugin.rb', repo.latest_commit_sha).splitlines():
for line in repo.get_file('plugin.rb', rev).splitlines():
if 'gem ' in line:
gemfile_text = gemfile_text + line + os.linesep
version_file_match = version_file_regex.match(line)
if version_file_match is not None:
filename = version_file_match.groups()[0]
content = repo.get_file(filename, rev)
with open(rubyenv_dir / filename, 'w') as f:
f.write(content)
if len(gemfile_text) > 0:
if os.path.isfile(gemfile):
os.remove(gemfile)