def setUpClass(cls): cls.git = GitRunner(make_default_options()) cls.base_temp_dir = tempfile.mkdtemp(prefix='git_test') cls.git_dir = os.path.join(cls.base_temp_dir, UPSTREAM_USER, TEST_REPO_NAME) os.makedirs(cls.git_dir) git_dir = cls.git_dir gitify = lambda args: 'git -C "{dir}" {args}'.format(dir=git_dir, args=args) check_subprocess_sequence([ gitify('init'), 'touch "{dir}/base_file"'.format(dir=git_dir), gitify('add "{dir}/base_file"'.format(dir=git_dir)), gitify('commit -a -m "feat(test): added file"'), gitify( 'tag {base_version} HEAD'.format(base_version=VERSION_BASE)), gitify( 'checkout -b {base_branch}'.format(base_branch=BRANCH_BASE)), gitify('checkout -b {a_branch}'.format(a_branch=BRANCH_A)), 'touch "{dir}/a_file"'.format(dir=git_dir), gitify('add "{dir}/a_file"'.format(dir=git_dir)), gitify('commit -a -m "feat(test): added a_file"'), gitify('tag {a_version} HEAD'.format(a_version=VERSION_A)), gitify('checkout -b {b_branch}'.format(b_branch=BRANCH_B)), 'touch "{dir}/b_file"'.format(dir=git_dir), gitify('add "{dir}/b_file"'.format(dir=git_dir)), gitify('commit -a -m "feat(test): added b_file"'), gitify('tag {b_version} HEAD'.format(b_version=VERSION_B)) ])
def __determine_repo_install_args(self): """Determine --spinnaker_dev-github_[owner|user] args for install script.""" options = self.options branch = options.git_branch owner = ('spinnaker' if options.github_user in ('default', 'upstream') else options.github_user) git_dir = os.path.dirname(__file__) if not branch: branch = GitRunner(options).query_local_repository_branch(git_dir) if not owner: url = (GitRunner(options).determine_remote_git_repository( git_dir).url) owner = re.search('github.com/(.+)/spinnaker', url).group(1) return [ '--spinnaker_dev_github_owner', owner, '--spinnaker_dev_github_branch', branch ]
def setUpClass(cls): cls.git = GitRunner(make_default_options()) cls.base_temp_dir = tempfile.mkdtemp(prefix='scm_test') origin_root = os.path.join(cls.base_temp_dir, 'origin_repos') repository_list = [ RemoteGitRepository.make_from_url(url) for url in [ os.path.join(origin_root, SCM_USER, 'RepoOne'), os.path.join(origin_root, SCM_USER, 'RepoTwo'), os.path.join(origin_root, TEST_USER, 'RepoTest') ] ] cls.TEST_SOURCE_REPOSITORIES = { repo.name: repo for repo in repository_list } for repo in repository_list: os.makedirs(repo.url) base_file = os.path.join(repo.url, '{name}-base.txt'.format(name=repo.name)) unique_file = os.path.join( repo.url, '{name}-unique.txt'.format(name=repo.name)) untagged_file = os.path.join( repo.url, '{name}-untagged.txt'.format(name=repo.name)) logging.debug('Initializing repository %s', repo.url) git_prefix = 'git -C "{dir}" '.format(dir=repo.url) run_git = lambda cmd: git_prefix + cmd check_subprocess_sequence([ # BASE_VERSION 'touch "{file}"'.format(file=base_file), run_git(' init'), run_git( 'add "{file}"'.format(file=os.path.basename(base_file))), run_git('commit -a -m "feat(first): first commit"'), run_git('tag {base_version} HEAD'.format( base_version=BASE_VERSION)), # Add Unique branch name per repo run_git('checkout -b {name}-branch'.format(name=repo.name)), 'touch "{file}"'.format(file=unique_file), run_git( 'add "{file}"'.format(file=os.path.basename(unique_file))), run_git('commit -a -m "chore(uniq): unique commit"'), # Add a common branch name, but without a tag on HEAD run_git('checkout master'), run_git('checkout -b {branch}'.format(branch=UNTAGGED_BRANCH)), 'touch "{file}"'.format(file=untagged_file), run_git('add "{file}"'.format( file=os.path.basename(untagged_file))), run_git('commit -a -m "chore(uniq): untagged commit"'), run_git('checkout master') ])
def __init__(self, factory, options, repository, branch_decorator, **kwargs): super(PullRequestCommandProcessor, self).__init__(factory, options, **kwargs) self.__repository = repository name = repository.name self.__named_scratch_dir = os.path.join(options.scratch_dir, name) self.__git_dir = os.path.join(options.root_path, name) self.__git = GitRunner(options) self.__branch_decorator = branch_decorator self.__head_branch = '{version}-{decorator}'.format( version=options.spinnaker_version, decorator=self.__branch_decorator)
def __init__(self, factory, options, **kwargs): source_repos = kwargs.pop('source_repositories', None) self.__max_threads = kwargs.pop('max_threads', 64) self.__git = kwargs.pop('git', None) or GitRunner(options) self.__scm = None if options.one_at_a_time: logging.debug('Limiting %s to one thread.', factory.name) self.__max_threads = 1 super(RepositoryCommandProcessor, self).__init__(factory, options, **kwargs) # filter needs the options, so this is after our super init call. self.__source_repositories = (self.filter_repositories(source_repos) if source_repos is not None else None)
def setUpClass(cls): cls.git = GitRunner(make_default_options()) cls.base_temp_dir = tempfile.mkdtemp(prefix='git_test') cls.git_dir = os.path.join(cls.base_temp_dir, 'commit_message_test') os.makedirs(cls.git_dir) git_dir = cls.git_dir gitify = lambda args: 'git -C "{dir}" {args}'.format(dir=git_dir, args=args) check_subprocess_sequence([ gitify('init'), 'touch "{dir}/base_file"'.format(dir=git_dir), gitify('add "{dir}/base_file"'.format(dir=git_dir)), gitify('commit -a -m "feat(test): added file"'), gitify( 'tag {base_version} HEAD'.format(base_version=VERSION_BASE)), gitify('checkout -b {patch_branch}'.format( patch_branch=cls.PATCH_BRANCH)), 'touch "{dir}/patch_file"'.format(dir=git_dir), gitify('add "{dir}/patch_file"'.format(dir=git_dir)), gitify('commit -a -m "fix(testA): added patch_file"'), gitify('checkout -b {minor_branch}'.format( minor_branch=cls.MINOR_BRANCH)), 'touch "{dir}/minor_file"'.format(dir=git_dir), gitify('add "{dir}/minor_file"'.format(dir=git_dir)), gitify('commit -a -m "chore(testB): added minor_file"'), gitify('checkout -b {major_branch}'.format( major_branch=cls.MAJOR_BRANCH)), 'touch "{dir}/major_file"'.format(dir=git_dir), gitify('add "{dir}/major_file"'.format(dir=git_dir)), gitify('commit -a -m' ' "feat(testC): added major_file\n' '\nInterestingly enough, this is a BREAKING CHANGE.' '"'), gitify('checkout -b {merged_branch}'.format( merged_branch=cls.MERGED_BRANCH)), gitify('reset --hard HEAD~3'), gitify('merge --squash HEAD@{1}') ]) env = dict(os.environ) if os.path.exists('/bin/true'): env['EDITOR'] = '/bin/true' elif os.path.exists('/usr/bin/true'): env['EDITOR'] = '/usr/bin/true' else: raise NotImplementedError('platform not supported for this test') check_subprocess('git -C "{dir}" commit'.format(dir=git_dir), env=env)