Commit 5cb4cd33 authored by Lorenz Huedepohl's avatar Lorenz Huedepohl
Browse files

Print notification when new commits are available

parent 2a710d20
Pipeline #67011 failed with stage
in 13 seconds
......@@ -47,6 +47,46 @@ prjconf_start_marker = "# Autogenerated by osc mpcdf_setup_repos, do not edit ti
prjconf_end_marker = "# End of autogenerated section\n"
def check_for_update():
import os
import sys
import time
from subprocess import check_output
if hasattr(sys.modules["mpcdf_common"], "checked_for_updates"):
setattr(sys.modules["mpcdf_common"], "checked_for_updates", 1)
plugin_dir = os.path.dirname(os.path.realpath(__file__))
git_dir = os.path.join(plugin_dir, ".git")
local_rev = check_output(["git", "--git-dir", git_dir, "rev-parse", "HEAD"]).strip()
# Check for update on server just once a day
rev_file = os.path.join(plugin_dir, ".remote_head_rev")
mtime = os.stat(rev_file).st_mtime
except FileNotFoundError:
mtime = 0
url = ""
if time.time() - mtime > 86400:
server_rev, _ = check_output(["git", "ls-remote", url, "master"]).split(maxsplit=1)
with open(rev_file, "wb") as fd:
with open(rev_file, "rb") as fd:
server_rev =
if server_rev != local_rev:
print("Your plugin directory is out-of-date, new commits available on", url, file=sys.stderr)
def compiler_module(compiler_repo):
return compiler_repo.replace("_", "/", 1).replace("_", ".")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment