Repository: 20c/ctl

Issue:
PyPI plugin: `target` config attribute should be `repository`
This is so it's in line with the version plugin, which currently uses `repository` to specify the target repository

The pypi plugin currently uses `repository` to specify which PyPI repository to use, this should change to `pypi_repository` as well.

Should do this before tagging 1.0.0 since it's a config schema change

Discussion:

Patch:
diff --git a/src/ctl/plugins/pypi.py b/src/ctl/plugins/pypi.py
index 5d979af..a6117af 100644
--- a/src/ctl/plugins/pypi.py
+++ b/src/ctl/plugins/pypi.py
@@ -32,7 +32,7 @@ class PyPIPluginConfig(release.ReleasePluginConfig):
     config_file = confu.schema.Str(help="path to pypi config file (e.g. ~/.pypirc)")
 
     # PyPI repository name, needs to exist in your pypi config file
-    repository = confu.schema.Str(
+    pypi_repository = confu.schema.Str(
         help="PyPI repository name - needs to exist " "in your pypi config file",
         default="pypi",
     )
@@ -55,16 +55,16 @@ class PyPIPlugin(release.ReleasePlugin):
 
     @property
     def dist_path(self):
-        return os.path.join(self.target.checkout_path, "dist", "*")
+        return os.path.join(self.repository.checkout_path, "dist", "*")
 
     def prepare(self):
         super(PyPIPlugin, self).prepare()
         self.shell = True
-        self.repository = self.get_config("repository")
+        self.pypi_repository = self.get_config("pypi_repository")
         self.pypirc_path = os.path.expanduser(self.config.get("config_file"))
         self.twine_settings = Settings(
             config_file=self.pypirc_path,
-            repository_name=self.repository,
+            repository_name=self.pypi_repository,
             sign=self.get_config("sign"),
             identity=self.get_config("identity"),
             sign_with=self.get_config("sign_with"),
diff --git a/src/ctl/plugins/release.py b/src/ctl/plugins/release.py
index bcfa1ce..dcae2f4 100644
--- a/src/ctl/plugins/release.py
+++ b/src/ctl/plugins/release.py
@@ -18,8 +18,8 @@ import ctl.plugins.git
 
 
 class ReleasePluginConfig(confu.schema.Schema):
-    target = confu.schema.Str(
-        help="target for release - should be a path "
+    repository = confu.schema.Str(
+        help="repository target for release - should be a path "
         "to a python package or the name of a "
         "repository type plugin",
         cli=False,
@@ -46,16 +46,16 @@ class ReleasePlugin(command.CommandPlugin):
             "version",
             nargs=1,
             type=str,
-            help="release version - if target is managed by git, "
+            help="release version - if repository is managed by git, "
             "checkout this branch/tag",
         )
 
         group.add_argument(
-            "target",
+            "repository",
             nargs="?",
             type=str,
-            default=plugin_config.get("target"),
-            help=ReleasePluginConfig().target.help,
+            default=plugin_config.get("repository"),
+            help=ReleasePluginConfig().repository.help,
         )
 
         sub = parser.add_subparsers(title="Operation", dest="op")
@@ -74,7 +74,7 @@ class ReleasePlugin(command.CommandPlugin):
 
         return {
             "group": group,
-            "confu_target": op_release_parser,
+            "confu_repository": op_release_parser,
             "op_release_parser": op_release_parser,
             "op_validate_parser": op_validate_parser,
         }
@@ -84,48 +84,48 @@ class ReleasePlugin(command.CommandPlugin):
         self.prepare()
         self.shell = True
 
-        self.set_target(self.get_config("target"))
+        self.set_repository(self.get_config("repository"))
         self.dry_run = kwargs.get("dry")
         self.version = kwargs.get("version")[0]
-        self.orig_branch = self.target.branch
+        self.orig_branch = self.repository.branch
 
         if self.dry_run:
             self.log.info("Doing dry run...")
-        self.log.info("Release target: {}".format(self.target))
+        self.log.info("Release repository: {}".format(self.repository))
 
         try:
-            self.target.checkout(self.version)
+            self.repository.checkout(self.version)
             op = self.get_op(kwargs.get("op"))
             op(**kwargs)
         finally:
-            self.target.checkout(self.orig_branch)
+            self.repository.checkout(self.orig_branch)
 
-    def set_target(self, target):
-        if not target:
-            raise ValueError("No target specified")
+    def set_repository(self, repository):
+        if not repository:
+            raise ValueError("No repository specified")
 
         try:
-            self.target = self.other_plugin(target)
-            if not isinstance(self.target, ctl.plugins.repository.RepositoryPlugin):
+            self.repository = self.other_plugin(repository)
+            if not isinstance(self.repository, ctl.plugins.repository.RepositoryPlugin):
                 raise TypeError(
                     "The plugin with the name `{}` is not a "
                     "repository type plugin and cannot be used "
-                    "as a target".format(target)
+                    "as a repository".format(repository)
                 )
         except KeyError:
-            self.target = os.path.abspath(target)
-            if not os.path.exists(self.target):
+            self.repository = os.path.abspath(repository)
+            if not os.path.exists(self.repository):
                 raise IOError(
                     "Target is neither a configured repository "
                     "plugin nor a valid file path: "
-                    "{}".format(self.target)
+                    "{}".format(self.repository)
                 )
 
-            self.target = ctl.plugins.git.temporary_plugin(
-                self.ctl, "{}__tmp_repo".format(self.plugin_name), self.target
+            self.repository = ctl.plugins.git.temporary_plugin(
+                self.ctl, "{}__tmp_repo".format(self.plugin_name), self.repository
             )
 
-        self.cwd = self.target.checkout_path
+        self.cwd = self.repository.checkout_path
 
     @expose("ctl.{plugin_name}.release")
     def release(self, **kwargs):


Test patch:
diff --git a/tests/test_plugin_pypi.py b/tests/test_plugin_pypi.py
index 20315ad..19813e2 100644
--- a/tests/test_plugin_pypi.py
+++ b/tests/test_plugin_pypi.py
@@ -53,35 +53,35 @@ def test_init():
 
 
 
-def test_set_target_git_path(tmpdir, ctlr):
+def test_set_repository_git_path(tmpdir, ctlr):
     """
-    Test setting build target: existing git repo via filepath
+    Test setting build repository: existing git repo via filepath
     """
 
     plugin, git_plugin = instantiate(tmpdir, ctlr)
 
-    plugin.set_target(git_plugin.checkout_path)
+    plugin.set_repository(git_plugin.checkout_path)
 
     assert plugin.dist_path == os.path.join(git_plugin.checkout_path,
                                             "dist", "*")
 
 
-def test_set_target_git_plugin(tmpdir, ctlr):
+def test_set_repository_git_plugin(tmpdir, ctlr):
     """
-    Test setting build target: existing git plugin
+    Test setting build repository: existing git plugin
     """
 
     plugin, git_plugin = instantiate(tmpdir, ctlr)
 
-    plugin.set_target(git_plugin.plugin_name)
+    plugin.set_repository(git_plugin.plugin_name)
 
     assert plugin.dist_path == os.path.join(git_plugin.checkout_path,
                                             "dist", "*")
 
 
-def test_set_target_error(tmpdir, ctlr):
+def test_set_repository_error(tmpdir, ctlr):
     """
-    Test setting invalid build target
+    Test setting invalid build repository
     """
 
     plugin, git_plugin = instantiate(tmpdir, ctlr)
@@ -89,17 +89,17 @@ def test_set_target_error(tmpdir, ctlr):
     # non existing path / plugin name
 
     with pytest.raises(IOError):
-        plugin.set_target("invalid target")
+        plugin.set_repository("invalid repository")
 
     # invalid plugin type
 
     with pytest.raises(TypeError):
-        plugin.set_target("test_pypi")
+        plugin.set_repository("test_pypi")
 
-    # no target
+    # no repository
 
     with pytest.raises(ValueError):
-        plugin.set_target(None)
+        plugin.set_repository(None)
 
 
 def test_build_dist(tmpdir, ctlr):
@@ -110,7 +110,7 @@ def test_build_dist(tmpdir, ctlr):
 
     plugin, git_plugin = instantiate(tmpdir, ctlr)
     plugin.prepare()
-    plugin.set_target(git_plugin.plugin_name)
+    plugin.set_repository(git_plugin.plugin_name)
     plugin._build_dist()
 
     assert os.path.exists(os.path.join(git_plugin.checkout_path,
@@ -126,7 +126,7 @@ def test_validate_dist(tmpdir, ctlr):
 
     plugin, git_plugin = instantiate(tmpdir, ctlr)
     plugin.prepare()
-    plugin.set_target(git_plugin.plugin_name)
+    plugin.set_repository(git_plugin.plugin_name)
     plugin._build_dist()
     plugin._validate_dist()