-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 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_scripts = os.path.isdir(".scripts")
+
+ 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_scripts:
+ logging.warning("Force removing .scripts directory")
+ if not options.dry_run: backup = util.safe_unlink(".scripts")
+ logging.info(".scripts backed up to %s" % backup)