Skip to content

Commit

Permalink
applying black formatter to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
bri25yu committed Sep 13, 2021
1 parent 2155095 commit 0beecd7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
21 changes: 18 additions & 3 deletions deploy/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,51 @@

from .path import repo_path, file_exists


def check(c: Connection):
return remote_reachable(c)


def update(c: Connection):
if repo_exists(c):
fetch(c)
else:
clone(c)


def repo_exists(c: Connection) -> bool:
return file_exists(c, "{}/HEAD".format(c.repo_path))


def remote_reachable(c: Connection) -> bool:
with c.cd(c.repo_path):
return c.run("git ls-remote {} HEAD".format(c.deploy.repo_url), warn=True, echo=True).ok
return c.run(
"git ls-remote {} HEAD".format(c.deploy.repo_url), warn=True, echo=True
).ok


def clone(c: Connection):
with c.cd(c.deploy_path):
c.run("git clone --bare {} {}".format(c.deploy.repo_url, c.repo_path))


def fetch(c: Connection):
with c.cd(c.repo_path):
c.run("git remote set-url origin {}".format(c.deploy.repo_url), echo=True)
c.run("git remote update", echo=True)
c.run("git fetch origin {0}:{0}".format(c.commit), echo=True)


def revision_number(c: Connection, revision: str) -> str:
with c.cd(c.repo_path):
return c.run("git rev-list --max-count=1 {} --".format(revision), echo=True).stdout.strip()
return c.run(
"git rev-list --max-count=1 {} --".format(revision), echo=True
).stdout.strip()


def create_archive(c: Connection):
with c.cd(c.repo_path):
c.run("git archive {} | tar -x -f - -C '{}'".format(c.commit, c.release_path), echo=True)
c.run(
"git archive {} | tar -x -f - -C '{}'".format(c.commit, c.release_path),
echo=True,
)
11 changes: 10 additions & 1 deletion deploy/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,38 @@

from fabric import Connection


def exists(c: Connection, path: str) -> bool:
return c.run("[[ -e {} ]]".format(path), warn=True).ok


def file_exists(c: Connection, path: str) -> bool:
return c.run("[[ -f {} ]]".format(path), warn=True).ok


def dir_exists(c: Connection, path: str) -> bool:
return c.run("[[ -d {} ]]".format(path), warn=True).ok


def deploy_path(c: Connection) -> str:
return posixpath.join(c.deploy.path.root, c.deploy.name)


def repo_path(c: Connection) -> str:
return posixpath.join(deploy_path(c), c.deploy.path.repo)


def releases_path(c: Connection) -> str:
return posixpath.join(deploy_path(c), c.deploy.path.releases)


def current_path(c: Connection) -> str:
return posixpath.join(deploy_path(c), c.deploy.path.current)


def shared_path(c: Connection) -> str:
return posixpath.join(deploy_path(c), c.deploy.path.shared)


def release_path(c: Connection) -> str:
return posixpath.join(releases_path(c), c.release)
return posixpath.join(releases_path(c), c.release)

0 comments on commit 0beecd7

Please sign in to comment.