- # deal with old-style migration
- if os.path.isfile(".scripts/old-version") and not os.path.isfile(".scripts-version"):
- os.rename(".scripts/old-version", ".scripts-version")
-
- if not has_git and has_scripts:
- if not options.force:
- raise CorruptedAutoinstallError(dir)
- elif has_git and not has_scripts:
- # can't force this
- raise AlreadyVersionedError(dir)
- elif has_git and has_scripts:
- if not options.force:
- raise AlreadyMigratedError(dir)
-
- if options.force:
- def rm_with_backup(file):
- prefix = "%s.bak" % file
- name = None
- for i in itertools.count():
- name = "%s.%d" % (prefix, i)
- if not os.path.exists(name):
- break
- os.rename(file, name)
- if has_git:
- logging.warning("Force removing .git directory")
- if not options.dry_run:
- rm_with_backup(".git")
- if has_scripts:
- logging.warning("Force removing .scripts directory")
- if not options.dry_run:
- rm_with_backup(".scripts")
-
-def make_deployment():
- try:
- return deploy.Deployment(".")
- except IOError as e:
- if e.errno == errno.ENOENT:
- raise NotAutoinstallError(dir)
- else: raise e
-
-def check_if_tag_exists(sh, repo, tag, version):
- # 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)
+ 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)