Skip to content

Commit

Permalink
Add initial version of publish; bump up version
Browse files Browse the repository at this point in the history
  • Loading branch information
jfischer committed Jun 20, 2019
1 parent e77098a commit 894a812
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dataworkspaces/commands/publish.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

from dataworkspaces.utils.git_utils import set_remote_origin

def publish_command(workspace_dir, remote_repository, batch, verbose):
set_remote_origin(workspace_dir, remote_repository, verbose=verbose)
print("Set remote origin to %s" % remote_repository)
26 changes: 26 additions & 0 deletions dataworkspaces/dws.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from .commands.snapshot import snapshot_command
from .commands.restore import restore_command
from .commands.status import status_command
from .commands.publish import publish_command
from .commands.push import push_command
from .commands.pull import pull_command
from .commands.clone import clone_command
Expand Down Expand Up @@ -336,6 +337,31 @@ def restore(ctx, workspace_dir, only, leave, tag_or_hash):
cli.add_command(restore)


@click.command()
@click.option('--workspace-dir', type=WORKSPACE_PARAM, default=DWS_PATHDIR)
@click.option('--skip', type=str, default=None,
metavar="RESOURCE1[,RESOURCE2,...]",
help="Comma-separated list of resource names that you wish to skip when pushing. The rest will be pushed to their remote origins, if applicable.")
@click.argument('remote-repository', type=str, default=None, required=True)
@click.pass_context
def publish(ctx, workspace_dir, skip, remote_repository):
"""Add a remote Git repository as the origin for the workspace and
do the initial push of the workspace and any other resources.
"""
ns = ctx.obj
if workspace_dir is None:
if ns.batch:
raise BatchModeError("--workspace-dir")
else:
workspace_dir = click.prompt("Please enter the workspace root dir",
type=WORKSPACE_PARAM)
publish_command(workspace_dir, remote_repository, ns.batch, ns.verbose)
push_command(workspace_dir, ns.batch, ns.verbose, only=None, skip=skip,
only_workspace=None)

cli.add_command(publish)


@click.command()
@click.option('--workspace-dir', type=WORKSPACE_PARAM, default=DWS_PATHDIR)
@click.option('--only', type=str, default=None,
Expand Down
4 changes: 4 additions & 0 deletions dataworkspaces/utils/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,7 @@ def get_json_file_from_remote(relpath, repo_dir, verbose):
if (tdir is not None) and isdir(tdir):
shutil.rmtree(tdir)
raise ConfigurationError("Problem retrieving file %s from remote"%relpath) from e

def set_remote_origin(repo_dir, remote_url, verbose):
call_subprocess([GIT_EXE_PATH, 'remote', 'add', 'origin', remote_url],
cwd=repo_dir, verbose=verbose)

0 comments on commit 894a812

Please sign in to comment.