Formatting
continuous-integration/drone/push Build is passing Details

pull/8/head
Inex Code 2022-01-11 08:41:25 +03:00
parent 0c61c1abb5
commit 650032bdab
3 changed files with 17 additions and 7 deletions

View File

@ -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():
""" """

View File

@ -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,12 +17,13 @@ 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.
@ -32,10 +34,17 @@ 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"])
os.chdir(current_working_directory) os.chdir(current_working_directory)
print("Done") print("Done")

View File

@ -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):