def __debug(command, dry=False): """ This method will be called, if the debug mode is on. """ if dry: command.append('--dry-run') Shell.debug(command) if dry: call(command) exit(1)
def __git_push(): command = ['git', 'push', '-u', 'origin', branch] branch = self.get_current_branch Shell.msg('Pushing branch ' + branch + ' to server...') if APISettings.DEBUG: Git.__debug(command, True) if not call(command): Shell.success('Push success!') return True return False
def __git_tag_delete(git_tag): """ Delete last tag. The function call will return 0 if the command success. """ command = ['git', 'tag', '-d', '\'' + git_tag + '\''] Shell.msg('Delete tag.') if APISettings.DEBUG: Git.__debug(command, False) if not call(command): return True return False
def __git_tag_push(): """ Push all tags. The function call will return 0 if the command success. """ command = ['git', 'push', 'origin', '--tags'] Shell.msg('Pushing tags...') if APISettings.DEBUG: Git.__debug(command, True) if not call(command): return True return False
def __git_tag_gpg(git_tag): """ Create new tag with GPG signature. The function call will return 0 if the command success. """ command = ['git', 'tag', '-s', git_tag, '-m', '\'' + git_tag + '\''] Shell.msg('Create signed tag version ' + git_tag + ' with GPG') if APISettings.DEBUG: Git.__debug(command, False) if not call(command): return True return False
def __git_tag(git_tag): """ Create new tag. The function call will return 0 if the command success. """ command = ['git', 'tag', '-a', git_tag, '-m', '\'' + git_tag + '\''] Shell.msg('Create tag from version ' + git_tag) if APISettings.DEBUG: Git.__debug(command, False) if not call(command): return True return False
def __git_commit(git_tag): """ Commit files to branch. The function call will return 0 if the command success. """ Shell.msg('Commit changes.') if APISettings.DEBUG: Shell.debug('Execute "git commit" in dry mode.') if not call(['git', 'commit', '-m', '\'' + git_tag + '\'', '--dry-run']): pass return True if not call(['git', 'commit', '-m', '\'' + git_tag + '\'']): return True return False
def __git_add(args=''): """ Add files to staging. The function call will return 0 if the command success. """ command = ['git', 'add', '.'] Shell.msg('Adding files...') if APISettings.DEBUG: Git.__debug(command, True) for key in args: command.append(key) if not call(command): pass return False
def tag(self, deploy_tag=''): """ Function is public. Create a tag for current commit / branch. :param deploy_tag: :return: """ if APISettings.SECURE_TAGGING and deploy_tag == APISettings.GIT_ACTIVATE_PRE_TAG: if self.check_existens_of_staging_tag_in_remote_repo(): pass else: Shell.fail('SECURE TAGGING is TRUE! That means, before you are able to create a production tag, ' \ 'you need to deploy the software on a staging envirnment.') return False if self.__git_tag(self.create_git_version_tag(deploy_tag)): return True return False