mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-25 21:41:27 +00:00
Formatting
This commit is contained in:
parent
0c61c1abb5
commit
650032bdab
|
@ -1,9 +1,8 @@
|
||||||
from selfprivacy_api.utils import ReadUserData
|
from selfprivacy_api.utils import ReadUserData
|
||||||
from selfprivacy_api.migrations.fix_nixos_config_branch import FixNixosConfigBranch
|
from selfprivacy_api.migrations.fix_nixos_config_branch import FixNixosConfigBranch
|
||||||
|
|
||||||
migrations = [
|
migrations = [FixNixosConfigBranch()]
|
||||||
FixNixosConfigBranch()
|
|
||||||
]
|
|
||||||
|
|
||||||
def run_migrations():
|
def run_migrations():
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -3,6 +3,7 @@ import subprocess
|
||||||
|
|
||||||
from selfprivacy_api.migrations.migration import Migration
|
from selfprivacy_api.migrations.migration import Migration
|
||||||
|
|
||||||
|
|
||||||
class FixNixosConfigBranch(Migration):
|
class FixNixosConfigBranch(Migration):
|
||||||
def get_migration_name(self):
|
def get_migration_name(self):
|
||||||
return "fix_nixos_config_branch"
|
return "fix_nixos_config_branch"
|
||||||
|
@ -16,13 +17,14 @@ class FixNixosConfigBranch(Migration):
|
||||||
|
|
||||||
def is_migration_needed(self):
|
def is_migration_needed(self):
|
||||||
"""Check the current branch of /etc/nixos and return True if it is rolling-testing"""
|
"""Check the current branch of /etc/nixos and return True if it is rolling-testing"""
|
||||||
nixos_config_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "HEAD"], start_new_session=True)
|
nixos_config_branch = subprocess.check_output(
|
||||||
|
["git", "rev-parse", "--abbrev-ref", "HEAD"], start_new_session=True
|
||||||
|
)
|
||||||
if nixos_config_branch.decode("utf-8").strip() == "rolling-testing":
|
if nixos_config_branch.decode("utf-8").strip() == "rolling-testing":
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def migrate(self):
|
def migrate(self):
|
||||||
"""Affected server pulled the config with the --single-branch flag.
|
"""Affected server pulled the config with the --single-branch flag.
|
||||||
Git config remote.origin.fetch has to be changed, so all branches will be fetched.
|
Git config remote.origin.fetch has to be changed, so all branches will be fetched.
|
||||||
|
@ -32,7 +34,14 @@ class FixNixosConfigBranch(Migration):
|
||||||
current_working_directory = os.getcwd()
|
current_working_directory = os.getcwd()
|
||||||
os.chdir("/etc/nixos")
|
os.chdir("/etc/nixos")
|
||||||
|
|
||||||
subprocess.check_output(["git", "config", "remote.origin.fetch", "+refs/heads/*:refs/remotes/origin/*"])
|
subprocess.check_output(
|
||||||
|
[
|
||||||
|
"git",
|
||||||
|
"config",
|
||||||
|
"remote.origin.fetch",
|
||||||
|
"+refs/heads/*:refs/remotes/origin/*",
|
||||||
|
]
|
||||||
|
)
|
||||||
subprocess.check_output(["git", "fetch", "--all"])
|
subprocess.check_output(["git", "fetch", "--all"])
|
||||||
subprocess.check_output(["git", "pull"])
|
subprocess.check_output(["git", "pull"])
|
||||||
subprocess.check_output(["git", "checkout", "master"])
|
subprocess.check_output(["git", "checkout", "master"])
|
||||||
|
|
|
@ -8,6 +8,8 @@ Migration has a function migrate() that does the migration
|
||||||
Migration has a function get_migration_name() that returns the migration name
|
Migration has a function get_migration_name() that returns the migration name
|
||||||
Migration has a function get_migration_description() that returns the migration description
|
Migration has a function get_migration_description() that returns the migration description
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Migration(ABC):
|
class Migration(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_migration_name(self):
|
def get_migration_name(self):
|
||||||
|
|
Loading…
Reference in a new issue