-def check_if_already_migrated(options):
- if os.path.isdir(".git") or os.path.isdir(".scripts"):
- if not options.force:
- raise AlreadyMigratedError(dir)
- else:
- if os.path.isdir(".git"):
- logging.warning("Force removing .git directory")
- if not options.dry_run: shutil.rmtree(".git")
- if os.path.isdir(".scripts"):
- logging.warning("Force removing .scripts directory")
- if not options.dry_run: shutil.rmtree(".scripts")
-
-def calculate_version():
- try:
- d = deploy.Deployment.fromDir(".")
- return d.getAppVersion()
- except IOError as e:
- if e.errno == errno.ENOENT:
- raise NotAutoinstallError(dir)
- else: raise e
-
-def calculate_repository(version):
- # calculate the repository we'll be pulling out of
- application = version.application
- app = application.name
- repo = os.path.join("/afs/athena.mit.edu/contrib/scripts/wizard/srv", app + ".git")
- if not os.path.isdir(repo):
- raise NoRepositoryError(app)
- return repo
-
-def calculate_tag(version):
- return "v%s-scripts" % version.version
-
-def check_if_tag_exists(sh, repo, tag):
- # check if the version we're trying to convert exists. We assume
- # a convention here, namely, v1.2.3-scripts is what we want. If
- # you broke the convention... shame on you.
- try:
- sh.call("git", "--git-dir", repo, "rev-parse", tag)
- except shell.CallError:
- raise NoTagError(version)
+def perform_force(options):
+ has_git = os.path.isdir(".git")
+ has_wizard = os.path.isdir(".wizard")
+
+ if has_git:
+ logging.warning("Force removing .git directory")
+ if not options.dry_run: backup = util.safe_unlink(".git")
+ logging.info(".git backed up to %s" % backup)
+ if has_wizard:
+ logging.warning("Force removing .wizard directory")
+ if not options.dry_run: backup = util.safe_unlink(".wizard")
+ logging.info(".wizard backed up to %s" % backup)