diff --git a/selfprivacy_api/migrations/__init__.py b/selfprivacy_api/migrations/__init__.py index 6a7723c..61097a7 100644 --- a/selfprivacy_api/migrations/__init__.py +++ b/selfprivacy_api/migrations/__init__.py @@ -1,9 +1,8 @@ from selfprivacy_api.utils import ReadUserData from selfprivacy_api.migrations.fix_nixos_config_branch import FixNixosConfigBranch -migrations = [ - FixNixosConfigBranch() -] +migrations = [FixNixosConfigBranch()] + def run_migrations(): """ diff --git a/selfprivacy_api/migrations/fix_nixos_config_branch.py b/selfprivacy_api/migrations/fix_nixos_config_branch.py index af36c67..26f4ff7 100644 --- a/selfprivacy_api/migrations/fix_nixos_config_branch.py +++ b/selfprivacy_api/migrations/fix_nixos_config_branch.py @@ -3,6 +3,7 @@ import subprocess from selfprivacy_api.migrations.migration import Migration + class FixNixosConfigBranch(Migration): def get_migration_name(self): return "fix_nixos_config_branch" @@ -16,12 +17,13 @@ class FixNixosConfigBranch(Migration): def is_migration_needed(self): """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": return True else: return False - def migrate(self): """Affected server pulled the config with the --single-branch flag. @@ -32,10 +34,17 @@ class FixNixosConfigBranch(Migration): current_working_directory = os.getcwd() 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", "pull"]) subprocess.check_output(["git", "checkout", "master"]) os.chdir(current_working_directory) - print("Done") \ No newline at end of file + print("Done") diff --git a/selfprivacy_api/migrations/migration.py b/selfprivacy_api/migrations/migration.py index e5a37db..b8ae261 100644 --- a/selfprivacy_api/migrations/migration.py +++ b/selfprivacy_api/migrations/migration.py @@ -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_description() that returns the migration description """ + + class Migration(ABC): @abstractmethod def get_migration_name(self):