Exemple #1
0
 def _apply_close_on_upgrade_or_removal(self, value):
     from gitpy import LocalRepository
     from infi.recipe.application_packager.utils.buildout import open_buildout_configfile
     with open_buildout_configfile(write_on_exit=True) as buildout:
         buildout.set("pack", "close-on-upgrade-or-removal", value)
     repository = LocalRepository('.')
     repository.add('buildout.cfg')
     repository.commit('HOSTDEV-1922 testing close-on-upgrade-or-removal={}'.format(value))
Exemple #2
0
def commit_changes_to_buildout(message):
    from os import curdir
    from gitpy import LocalRepository
    repository = LocalRepository(curdir)
    if "buildout.cfg" not in [modified_file.filename for modified_file in repository.getChangedFiles()]:
        return
    repository.add("buildout.cfg")
    repository.commit("buildout.cfg: " + message)
Exemple #3
0
def commit_changes_to_buildout(message):
    import os
    from gitpy import LocalRepository
    repository = LocalRepository(os.curdir)
    # workaround https://github.com/msysgit/git/issues/79
    os.system("git status")
    if "buildout.cfg" not in [modified_file.filename for modified_file in repository.getChangedFiles()]:
        return
    repository.add("buildout.cfg")
    repository.commit("buildout.cfg: " + message)
Exemple #4
0
 def _apply_close_on_upgrade_or_removal(self, value):
     from gitpy import LocalRepository
     from infi.recipe.application_packager.utils.buildout import open_buildout_configfile
     with open_buildout_configfile(write_on_exit=True) as buildout:
         buildout.set("pack", "close-on-upgrade-or-removal", value)
     repository = LocalRepository('.')
     repository.add('buildout.cfg')
     repository.commit(
         'HOSTDEV-1922 testing close-on-upgrade-or-removal={}'.format(
             value))
Exemple #5
0
def create_repo():
    returned = LocalRepository(get_temporary_location())
    returned.init()
    for i in range(10):
        filename = "file_%s.txt" % i
        full_filename = os.path.join(returned.path, filename)
        with open(full_filename, "wb") as f:
            print >>f, "initial content"
        returned.add(filename)
    returned.commit(message="initial")
    return returned
Exemple #6
0
 def unfreeze(self):
     from infi.projector.helper.utils import unfreeze_versions
     from gitpy import LocalRepository
     from os import curdir
     unfreeze_versions(self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Unfreezing dependencies")
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #7
0
 def unfreeze(self):
     from infi.projector.helper.utils import unfreeze_versions
     from gitpy import LocalRepository
     from os import curdir
     versions = unfreeze_versions(self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Unfreezing dependencies")
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #8
0
def commit_changes_to_buildout(message):
    import os
    from gitpy import LocalRepository
    repository = LocalRepository(os.curdir)
    # workaround https://github.com/msysgit/git/issues/79
    os.system("git status")
    if "buildout.cfg" not in [
            modified_file.filename
            for modified_file in repository.getChangedFiles()
    ]:
        return
    repository.add("buildout.cfg")
    repository.commit("buildout.cfg: " + message)
Exemple #9
0
    def unfreeze(self):
        from gitpy import LocalRepository
        from os import curdir
        with open_buildout_configfile(write_on_exit=True) as buildout_cfg:
            if not buildout_cfg.has_section('js-requirements'):
                print("Missing js-requirements section")
                return
            buildout_cfg.remove_option("buildout", "js_versions")
            buildout_cfg.remove_section("js_versions")

        # Git operations
        repository = LocalRepository(curdir)
        if self.arguments.get("--commit-changes", False):
            repository.add("buildout.cfg")
            repository.commit("Unfreezing javascript dependencies")
        push_changes = self.arguments.get("--push-changes", False)
        if push_changes:
            repository._executeGitCommandAssertSuccess("git push")
Exemple #10
0
 def freeze(self):
     from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile
     from infi.projector.plugins.builtins.devenv import DevEnvPlugin
     from gitpy import LocalRepository
     from os import curdir
     from re import sub, findall, MULTILINE
     plugin = DevEnvPlugin()
     plugin.arguments = {
         '--newest': self.arguments.get("--newest", False),
         '--use-isolated-python': True
     }
     with open_tempfile() as tempfile:
         with buildout_parameters_context([
                 "buildout:update-versions-file={0}".format(tempfile),
                 "buildout:versions="
         ]):
             plugin.build()
         with open(tempfile) as fd:
             content = fd.read()
         post_releases = findall(r'^[^#].* = .*\.post.*', content,
                                 MULTILINE)
         if post_releases:
             if self.arguments.get('--allow-post-releases'):
                 pass
             elif self.arguments.get('--strip-suffix-from-post-releases'):
                 content = sub(r'\.post\d+', '', content)
             else:
                 msg = "freeze found the follwing post-releases, see the dependency tree above:\n{}"
                 formatted_post_releases = "\n".join(
                     item for item in post_releases)
                 logger.info(content)
                 logger.error(msg.format(formatted_post_releases))
                 raise SystemExit(1)
         with open(tempfile, 'w') as fd:
             fd.write("[versions]\n" + "\n".join(set(content.splitlines())))
         freeze_versions(
             tempfile, self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Freezing dependencies", allowEmpty=True)
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #11
0
    def freeze(self):
        from gitpy import LocalRepository
        from os import curdir
        import json

        # Read/write the buildout.cfg
        with open_buildout_configfile(write_on_exit=True) as buildout_cfg:
            if not buildout_cfg.has_section('js-requirements'):
                print("Missing js-requirements section")
                return
            packages_path = buildout_cfg.get(
                'js-requirements', 'js-directory') or self.DEFAULT_DIRECTORY
            try:
                with open(os.path.join(packages_path, '.package-lock.json'),
                          'r') as pljson:
                    selected_versions = json.load(pljson)
                    if buildout_cfg.has_section("js_versions"):
                        buildout_cfg.remove_section("js_versions")
                    buildout_cfg.add_section("js_versions")
                for key in sorted(selected_versions.keys(),
                                  key=lambda s: s.lower()):
                    buildout_cfg.set("js_versions", key,
                                     selected_versions[key])
                buildout_cfg.set('buildout', 'js_versions', 'True')
            except IOError as e:
                import errno
                print(str(e))
                if hasattr(e, 'errno') and e.errno == errno.ENOENT:
                    print(
                        '.package-lock.json file is missing, try running projector devenv build to create the file'
                    )

        # Git operations
        repository = LocalRepository(curdir)
        if self.arguments.get("--commit-changes", False):
            repository.add("buildout.cfg")
            repository.commit("Freezing javascript dependencies")
        push_changes = self.arguments.get("--push-changes", False)
        if push_changes:
            repository._executeGitCommandAssertSuccess("git push")
Exemple #12
0
 def freeze(self):
     from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile
     from infi.projector.plugins.builtins.devenv import DevEnvPlugin
     from gitpy import LocalRepository
     from os import curdir
     plugin = DevEnvPlugin()
     plugin.arguments = {'--newest': self.arguments.get("--newest", False)}
     with open_tempfile() as tempfile:
         with buildout_parameters_context(["buildout:update-versions-file={0}".format(tempfile)]):
             plugin.build()
         with open(tempfile) as fd:
             content = fd.read()
         with open(tempfile, 'w') as fd:
             fd.write("[versions]\n" + content)
         freeze_versions(tempfile, self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Freezing dependencies")
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #13
0
def do_a_refactoring_change():
    # HOSTDEV-1781
    from gitpy import LocalRepository
    from os import rename
    scripts_dir = os.path.join("src", "infi", "recipe", "application_packager", "scripts")
    refactoring_dir = os.path.join(scripts_dir, "refactoring")
    scripts_init = os.path.join(scripts_dir, "__init__.py")
    refactoring_py = "{}.py".format(refactoring_dir)
    if not os.path.exists(refactoring_dir):
        return
    # move the file
    rename(os.path.join(refactoring_dir, "__init__.py"), refactoring_py)

    # change the files
    apply_change_in_file(refactoring_py)
    apply_change_in_file(scripts_init)

    # commit the changes
    repository = LocalRepository('.')
    repository.delete(refactoring_dir, recursive=True, force=True)
    repository.add(refactoring_py)
    repository.add(scripts_init)
    repository.commit("HOSTDEV-1781 refactoring scripts/refactoring")
Exemple #14
0
 def freeze(self):
     from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile
     from infi.projector.plugins.builtins.devenv import DevEnvPlugin
     from gitpy import LocalRepository
     from os import curdir
     from re import sub, findall, MULTILINE
     plugin = DevEnvPlugin()
     plugin.arguments = {'--newest': self.arguments.get("--newest", False),
                         '--use-isolated-python': True}
     with open_tempfile() as tempfile:
         with buildout_parameters_context(["buildout:update-versions-file={0}".format(tempfile),
                                           "buildout:versions="]):
             plugin.build()
         with open(tempfile) as fd:
             content = fd.read()
         post_releases = findall(r'^[^#].* = .*\.post.*', content, MULTILINE)
         if post_releases:
             if self.arguments.get('--allow-post-releases'):
                 pass
             elif self.arguments.get('--strip-suffix-from-post-releases'):
                 content = sub(r'\.post\d+', '', content)
             else:
                 msg = "freeze found the follwing post-releases, see the dependency tree above:\n{}"
                 formatted_post_releases = "\n".join(item for item in post_releases)
                 logger.info(content)
                 logger.error(msg.format(formatted_post_releases))
                 raise SystemExit(1)
         with open(tempfile, 'w') as fd:
             fd.write("[versions]\n" + "\n".join(set(content.splitlines())))
         freeze_versions(tempfile, self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Freezing dependencies", allowEmpty=True)
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #15
0
 def freeze(self):
     from infi.projector.helper.utils import freeze_versions, buildout_parameters_context, open_tempfile
     from infi.projector.plugins.builtins.devenv import DevEnvPlugin
     from gitpy import LocalRepository
     from os import curdir
     plugin = DevEnvPlugin()
     plugin.arguments = {'--newest': self.arguments.get("--newest", False)}
     with open_tempfile() as tempfile:
         with buildout_parameters_context(
             ["buildout:update-versions-file={0}".format(tempfile)]):
             plugin.build()
         with open(tempfile) as fd:
             content = fd.read()
         with open(tempfile, 'w') as fd:
             fd.write("[versions]\n" + content)
         freeze_versions(
             tempfile, self.arguments.get("--with-install-requires", False))
     if self.arguments.get("--commit-changes", False):
         repository = LocalRepository(curdir)
         repository.add("buildout.cfg")
         repository.commit("Freezing dependencies")
     push_changes = self.arguments.get("--push-changes", False)
     if push_changes:
         repository._executeGitCommandAssertSuccess("git push")
Exemple #16
0
def do_a_refactoring_change():
    # HOSTDEV-1781
    from gitpy import LocalRepository
    from os import rename
    scripts_dir = os.path.join("src", "infi", "recipe", "application_packager",
                               "scripts")
    refactoring_dir = os.path.join(scripts_dir, "refactoring")
    scripts_init = os.path.join(scripts_dir, "__init__.py")
    refactoring_py = "{}.py".format(refactoring_dir)
    if not os.path.exists(refactoring_dir):
        return
    # move the file
    rename(os.path.join(refactoring_dir, "__init__.py"), refactoring_py)

    # change the files
    apply_change_in_file(refactoring_py)
    apply_change_in_file(scripts_init)

    # commit the changes
    repository = LocalRepository('.')
    repository.delete(refactoring_dir, recursive=True, force=True)
    repository.add(refactoring_py)
    repository.add(scripts_init)
    repository.commit("HOSTDEV-1781 refactoring scripts/refactoring")
Exemple #17
0
def commit_changes_to_manifest_in(message):
    from os import curdir
    from gitpy import LocalRepository
    repository = LocalRepository(curdir)
    repository.add("MANIFEST.in")
    repository.commit("MANIFEST.in: " + message)
Exemple #18
0
def commit_changes_to_manifest_in(message):
    from os import curdir
    from gitpy import LocalRepository
    repository = LocalRepository(curdir)
    repository.add("MANIFEST.in")
    repository.commit("MANIFEST.in: " + message)