# Path: badwolf/extensions.py



import os
import logging
import git
from badwolf.extensions import bitbucket
    Clone repository from BitBucket to local
    '''
    def __init__(self, context):
        self.context = context
        self.commit_hash = context.source['commit']['hash']

    def clone(self):
        clone_path = self.context.clone_path
        source_repo = self.context.source['repository']['full_name']
        if self.context.clone_depth > 0:
            if self.context.target:
                # Pull request
                branch = self.context.target['branch']['name']
            else:
                branch = self.context.source['branch']['name']
            # Use shallow clone to speed up
            clone_kwargs = {
                'depth': self.context.clone_depth,
                'branch': branch,
            }
            if self.context.type == 'commit':
                # ci retry on commit
                clone_kwargs['no_single_branch'] = True
            bitbucket.clone(
                source_repo,
                clone_path,
                **clone_kwargs
            )
        else:
            # Full clone for ci retry in single commit

# Path: badwolf/extensions.py



# Path: badwolf/cloner.py
import os
import logging
import git
from badwolf.extensions import bitbucket

    Clone repository from BitBucket to local
    '''
    def __init__(self, context):
        self.context = context
        self.commit_hash = context.source['commit']['hash']

    def clone(self):
        clone_path = self.context.clone_path
        source_repo = self.context.source['repository']['full_name']
        if self.context.clone_depth > 0:
            if self.context.target:
                # Pull request
                branch = self.context.target['branch']['name']
            else:
                branch = self.context.source['branch']['name']
            # Use shallow clone to speed up
            clone_kwargs = {
                'depth': self.context.clone_depth,
                'branch': branch,
            }
            if self.context.type == 'commit':
                # ci retry on commit
                clone_kwargs['no_single_branch'] = True
            bitbucket.clone(
                source_repo,
                clone_path,
                **clone_kwargs
            )
        else:
            # Full clone for ci retry in single commit

            bitbucket.clone(source_repo, clone_path)