@classmethod
    def initialize_ticket_folder(cls, ticket_url, path, jira):
        path = os.path.realpath(path)

        metadata_path = os.path.join(
            path,
            constants.METADATA_DIR,
        )
        os.mkdir(metadata_path)

        with io.open(
            os.path.join(metadata_path, 'issue_url'),
            'w',
            encoding='utf-8'
        ) as out:
            out.write(six.text_type(ticket_url))

        # Create bare git repository so we can easily detect changes.
        subprocess.check_call(
            (
                'git',
                '--bare',
                'init',
                os.path.join(
                    metadata_path,
                    'git',
                )
            ),
            stdout=subprocess.PIPE
        )
        subprocess.check_call((
            'git',
            'config',
            '--file=%s' % os.path.join(
                metadata_path,
                'git',
                'config'
            ),
            'core.excludesfile',
            constants.GIT_IGNORE_FILE,
        ))

        excludes_path = os.path.join(metadata_path, 'git', 'info', 'exclude')
        with io.open(excludes_path, 'w', encoding='utf-8') as gitignore:
            gitignore.write(
                six.text_type('\n').join(
                    [
                        '%s/git' % constants.METADATA_DIR,
                        '%s/shadow' % constants.METADATA_DIR,
                        '%s/operation.log' % constants.METADATA_DIR,
                    ]
                )
            )

        instance = cls(path, jira, migrate=False)
        instance.log(
            'Ticket folder for issue %s created at %s',
            (instance.ticket_number, instance.path, )
        )
        instance.run_git_command(
            'add', '-A'
        )
        instance.run_git_command(
            'commit', '--allow-empty', '-m', 'Initialized'
        )
        instance.run_migrations(init=True)

        comment_path = instance.get_local_path(constants.TICKET_NEW_COMMENT)
        with io.open(comment_path, 'w', encoding='utf-8') as out:
            out.write(six.text_type(''))

        return instance
dataset/ETHPy150Open coddingtonbear/jirafs/jirafs/ticketfolder.py/TicketFolder.initialize_ticket_folder/original