How to use the koji.daemon.SCM function in koji

To help you get started, we’ve selected a few koji examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github koji-project / koji / tests / test_scm.py View on Github external
def test_get_source_other(self, popen):
        popen.return_value.wait.return_value = 0
        popen.return_value.communicate = mock.MagicMock()
        popen.return_value.communicate.return_value = ('hash ', 'any')

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                     uploadpath=self.uploadpath, logfile=self.logfile)

        source = scm.get_source()
        self.assertEqual(source, {'url': url, 'source': url})
github koji-project / koji / tests / test_scm.py View on Github external
"git+ssh://server2/other/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "svn://server/path/to/code#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "svn+ssh://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "cvs://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "cvs+ssh://server/some/path#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            ]
        bad = [
            "http://localhost/foo.html",
            "foo-1.1-1.src.rpm",
            "https://server/foo-1.1-1.src.rpm",
            "git:foobar",
            "https:foo/bar",
            "https://",
            ]
        for url in good:
            self.assertTrue(SCM.is_scm_url(url))
        for url in bad:
            self.assertFalse(SCM.is_scm_url(url))
github koji-project / koji / tests / test_scm.py View on Github external
self.assertEqual(scm.source_cmd, ['make', 'sources'])

        url = "git://nocommon/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])

        url = "git://srccmd/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, ['fedpkg', 'sources'])

        url = "git://nosrc/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, None)

        url = "git://mixed/foo/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])

        url = "git://mixed/bar/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, True)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])
github koji-project / koji / tests / test_scm.py View on Github external
def test_checkout_gitssh_nocommon(self):

        url = "git+ssh://user@nocommon/koji.git#asdasd"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['git', 'clone', '-n', 'git+ssh://user@nocommon/koji.git',
                self.tempdir + '/koji']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        cmd = ['git', 'reset', '--hard', 'asdasd']
        call2 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir + '/koji',
                        logerror=1, append=True, env=None)
        self.log_output.assert_has_calls([call1, call2])
github koji-project / koji / tests / test_scm.py View on Github external
bad = [
            "git://user@@server/foo.git#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "git://user:pass@server/foo.git#bab0c73900241ef5c465d7e873e9d8b34c948e67",
            "git://server/foo.git;params=not_allowed",
            "git://server#asdasd",  # no path
            "git://server/foo.git",  # no fragment
            "http://localhost/foo.html",
            "git://@localhost/foo/?a=bar/",
            "http://localhost/foo.html?a=foo/",
            "foo-1.1-1.src.rpm",
            "git://",
            "https://server/foo-1.1-1.src.rpm",
            ]
        for url in bad:
            with self.assertRaises(koji.GenericError):
                scm = SCM(url)

        url = "git://user@server/foo.git#bab0c73900241ef5c465d7e873e9d8b34c948e67"
        scm = SCM(url)
        self.assertEqual(scm.scheme, 'git://')
        self.assertEqual(scm.user, 'user')
        self.assertEqual(scm.host, 'server')
        self.assertEqual(scm.repository, '/foo.git')
        self.assertEqual(scm.module, '')
        self.assertEqual(scm.revision, 'bab0c73900241ef5c465d7e873e9d8b34c948e67')
        self.assertEqual(scm.use_common, True)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])
        self.assertEqual(scm.scmtype, 'GIT')
github koji-project / koji / tests / test_scm.py View on Github external
def test_checkout_svn_ssh(self):

        url = "svn+ssh://user@nocommon/dist?rpms/foo/EL3#revision"
        scm = SCM(url)
        scm.assert_allowed(self.config)
        scm.checkout(self.tempdir, session=self.session,
                uploadpath=self.uploadpath, logfile=self.logfile)
        self.assertEqual(scm.use_common, False)
        self.symlink.assert_not_called()
        # expected commands
        cmd = ['svn', 'checkout', '-r', 'revision',
                'svn+ssh://user@nocommon/dist/rpms/foo/EL3', 'rpms/foo/EL3']
        call1 = mock.call(self.session, cmd[0], cmd, self.logfile,
                        self.uploadpath, cwd=self.tempdir, logerror=1,
                        append=False, env=None)
        self.log_output.assert_has_calls([call1])
github koji-project / koji / tests / test_scm.py View on Github external
nocommon:*:no
            srccmd:*:no:fedpkg,sources
            nosrc:*:no:
            mixed:/foo/*:no
            mixed:/bar/*:yes
            mixed:/baz/*:no:fedpkg,sources
            '''

        url = "git://default/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, True)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])

        url = "git://nocommon/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, ['make', 'sources'])

        url = "git://srccmd/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, ['fedpkg', 'sources'])

        url = "git://nosrc/koji.git#1234"
        scm = SCM(url)
        scm.assert_allowed(config)
        self.assertEqual(scm.use_common, False)
        self.assertEqual(scm.source_cmd, None)
github koji-project / koji / tests / test_scm.py View on Github external
"git+ssh://maybeserver/path1#1234",
            ]
        bad = [
            "cvs://badserver/projects/42#ref",
            "svn://badserver/projects/42#ref",
            "git://maybeserver/badpath/project#1234",
            "git://maybeserver//badpath/project#1234",
            "git://maybeserver////badpath/project#1234",
            "git://maybeserver/./badpath/project#1234",
            "git://maybeserver//.//badpath/project#1234",
            "git://maybeserver/goodpath/../badpath/project#1234",
            "git://maybeserver/goodpath/..//badpath/project#1234",
            "git://maybeserver/..//badpath/project#1234",
            ]
        for url in good:
            scm = SCM(url)
            scm.assert_allowed(config)
        for url in bad:
            scm = SCM(url)
            try:
                scm.assert_allowed(config)
            except koji.BuildError:
                pass
            else:
                raise AssertionError("allowed bad url: %s" % url)
github containerbuildsystem / koji-containerbuild / koji_containerbuild / plugins / builder_containerbuild.py View on Github external
def fetchDockerfile(self, src, build_tag):
        """
        Gets Dockerfile. Roughly corresponds to getSRPM method of build task
        """
        scm = SCM(src)
        scm.assert_allowed(self.options.allowed_scms)
        scmdir = os.path.join(self.workdir, 'sources')

        koji.ensuredir(scmdir)

        logfile = os.path.join(self.workdir, 'checkout-for-labels.log')
        uploadpath = self.getUploadDir()

        koji.ensuredir(uploadpath)

        self.run_callbacks('preSCMCheckout', scminfo=scm.get_info(), build_tag=build_tag,
                           scratch=self.opts.get('scratch', False))

        # Check out sources from the SCM
        sourcedir = scm.checkout(scmdir, self.session, uploadpath, logfile)