Exemple #1
0
def gh_register():
    """Create a repository at GitHub and push it your local repository."""
    _adjust_options()
    repo = _get_repo(os.getcwd())
    project_name = options.setup.name
    project_description = options.setup.get('description','')
    remote_name = options.gh_pages.remote_name
    master_branch = options.gh_pages.master_branch
    credentials = Credentials.get_credentials(repo)
    if not credentials:
        sys.exit('Your github name and token git config are not set.'
                 'Check http://github.com/blog/170-token-authentication' % os.getcwd())
    project = dry(
        "Create a repository called %s at %s's GitHub account..." % (
            project_name, credentials.user),
        repo.register,
        project_name,
        credentials,
        description=project_description,
        is_public=True,
        remote_name=remote_name,
        master_branch=master_branch)
    if project is not None:
        info('Opening your project home pages:%s', project.url.http)
        webbrowser.open(project.url.http)
Exemple #2
0
def gh_register():
    """Create a repository at GitHub and push it your local repository."""
    _adjust_options()
    repo = _get_repo(os.getcwd())
    project_name = options.setup.name
    project_description = options.setup.get('description', '')
    remote_name = options.gh_pages.remote_name
    master_branch = options.gh_pages.master_branch
    credentials = Credentials.get_credentials(repo)
    if not credentials:
        sys.exit('Your github name and token git config are not set.'
                 'Check http://github.com/blog/170-token-authentication' %
                 os.getcwd())
    project = dry("Create a repository called %s at %s's GitHub account..." %
                  (project_name, credentials.user),
                  repo.register,
                  project_name,
                  credentials,
                  description=project_description,
                  is_public=True,
                  remote_name=remote_name,
                  master_branch=master_branch)
    if project is not None:
        info('Opening your project home pages:%s', project.url.http)
        webbrowser.open(project.url.http)
Exemple #3
0
    def test_register(self, urlopen_mock):
        urlopen_mock.return_value = \
            StringIO(TestProject.GITHUB_JSON_RESPONSE)
        with TempDir() as tmp:
            repo = GitHubRepo.create(tmp)
            git_mock = Mock()
            repo.git = git_mock
            credentials = Credentials('damien', 'xyz')
            repo.register('foo',
                          credentials=credentials,
                          description='just a test',
                          is_public=True)

            # test project creation
            url, data = urlopen_mock.call_args[0]
            data_dict = dict(cgi.parse_qsl(data))
            eq_('http://github.com/api/v2/json/repos/create', url)
            eq_('foo', data_dict['name'])
            eq_('just a test', data_dict['description'])
            eq_('1', data_dict['public'])
            eq_('damien', data_dict['login'])
            eq_('xyz', data_dict['token'])

            # test remote added
            eq_(('add', 'origin', '[email protected]:damien/foo.git'),
                git_mock.remote.call_args[0])
            eq_(('origin', 'master'), git_mock.push.call_args[0])
 def test_get_credential(self):
     with TempDir() as tmp:
         repo = Repo.init_bare(path(tmp) / 'repo.git')
         repo.git.config('github.user', 'damien')
         repo.git.config('github.token', 'xyz')
         c = Credentials.get_credentials(repo)
         eq_('damien', c.user)
         eq_('xyz', c.token)
Exemple #5
0
 def test_get_credential(self):
     with TempDir() as tmp:
         repo = Repo.init_bare(path(tmp) / 'repo.git')
         repo.git.config('github.user', 'damien')
         repo.git.config('github.token', 'xyz')
         c = Credentials.get_credentials(repo)
         eq_('damien', c.user)
         eq_('xyz', c.token)
Exemple #6
0
def gh_register():
    """Create a repository at GitHub and push it your local repository."""
    repo = _get_repo(os.getcwd())
    project_name = options.setup.name
    project_description = options.setup.get('description','')
    remote_name = options.gh_pages.remote_name
    master_branch = options.gh_pages.master_branch
    credentials = Credentials.get_credentials(repo)
    project = dry(
        "Create a repository called %s at %s's GitHub account..." % (
            project_name, credentials.user),
        repo.register,
        project_name,
        credentials,
        description=project_description,
        is_public=True,
        remote_name=remote_name,
        master_branch=master_branch)
    if project is not None:
        info('Opening your project home pages:%s', project.url.http)
        webbrowser.open(project.url.http)
Exemple #7
0
def gh_register():
    """Create a repository at GitHub and push it your local repository."""
    _adjust_options()
    repo = _get_repo(os.getcwd())
    project_name = options.setup.name
    project_description = options.setup.get('description', '')
    remote_name = options.gh_pages.remote_name
    master_branch = options.gh_pages.master_branch
    credentials = Credentials.get_credentials(repo)
    project = dry("Create a repository called %s at %s's GitHub account..." %
                  (project_name, credentials.user),
                  repo.register,
                  project_name,
                  credentials,
                  description=project_description,
                  is_public=True,
                  remote_name=remote_name,
                  master_branch=master_branch)
    if project is not None:
        info('Opening your project home pages:%s', project.url.http)
        webbrowser.open(project.url.http)
Exemple #8
0
    def test_create(self, urlopen_mock):
        urlopen_mock.return_value = StringIO(self.GITHUB_JSON_RESPONSE)
        credentials = Credentials('damien', 'xyz')
        project = GitHubProject.create('foo',
                                       credentials,
                                       description='just a test',
                                       is_public=True)

        # test request to github
        url, data = urlopen_mock.call_args[0]
        data_dict = dict(cgi.parse_qsl(data))
        eq_('http://github.com/api/v2/json/repos/create', url)
        eq_('foo', data_dict['name'])
        eq_('just a test', data_dict['description'])
        eq_('1', data_dict['public'])
        eq_('damien', data_dict['login'])
        eq_('xyz', data_dict['token'])

        # test returned project
        eq_('foo', project.name)
        eq_('damien', project.owner)
        eq_('just a test', project.description)
        eq_(True, project.is_public)
        eq_('[email protected]:damien/foo.git', project.url.ssh)
Exemple #9
0
 def test_new(self):
     c = Credentials(user='******', token='xyz')
     eq_('damien', c.user)
     eq_('xyz', c.token)