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.migrations.fix_nixos_config_branch import FixNixosConfigBranch
|
||||
|
||||
migrations = [
|
||||
FixNixosConfigBranch()
|
||||
]
|
||||
migrations = [FixNixosConfigBranch()]
|
||||
|
||||
|
||||
def run_migrations():
|
||||
"""
|
||||
|
|
|
@ -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")
|
||||
print("Done")
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue