def __call__(self): scm.tested_for_scms(('svn', 'gitsvn'), '.') svn_url = scm.get_svn_url('.').split('/') svn_root_url = scm.get_package_root_url('.').split('/') package_name = scm.get_package_name('.') path = os.path.abspath(os.path.join( (len(svn_url) - len(svn_root_url) - 1) * '../', package_name.replace('.', '/'), 'version.txt', )) if not os.path.isfile(path): output.error('Could not find file %s' % path, exit=1) version = open(path).read().strip() print ' Version of %s: %s' % ( output.colorize(package_name, output.WARNING), output.colorize(version, output.WARNING), )
def create_tag(self): output.part_title('Creating subversion tag') if scm.is_subversion('.'): root_url = scm.get_package_root_url('.') trunk_url = scm.get_svn_url('.') tag_url = os.path.join(root_url, 'tags', self.new_tag_version) cmd = 'svn cp %s %s -m "creating tag %s for package %s"' % ( trunk_url, tag_url, self.new_tag_version, svn.get_package_name('.'), ) runcmd(cmd) elif scm.is_git_svn('.'): cmd = 'git svn tag %s' % self.new_tag_version runcmd(cmd) git.pull_changes('.') elif scm.is_git('.'): runcmd('git tag -a %s -m "tagged by ftw.manager"' % self.new_tag_version, log=True) runcmd('git push origin --tags', log=True)
def analyse(self): output.part_title('Checking subversion project') if not scm.is_scm('.'): # without subversion or gitsvn it doesnt work... output.error('Current directory is not a repository of type svn, ' 'git-svn, git.', exit=True) # update newest remote changes if scm.is_git('.') or scm.is_git_svn('.'): git.pull_changes('.') git.push_committed_changes('.') elif scm.is_subversion('.'): svn.update('.') # remote should be there if scm.is_git('.') and not scm.is_git_svn('.'): if not git.has_remote('origin'): output.error('There is no remote "origin", which is needd', exit=True) # run it at repo root if scm.is_subversion('.') or scm.is_git_svn('.'): root_svn = scm.get_package_root_url('.') if not svn.check_project_layout(root_svn, raise_exception=False, ask_for_creation=False): # we should have the folders trunk, tags, branches in the project output.error('Project does not have default layout with trunk, ' +\ 'tags and branches. At least one folder is missing.', exit=True) if not self.options.release_egg_only: here_url = scm.get_svn_url('.') here_root = scm.get_package_root_url('.') is_trunk = here_url == here_root +'/trunk' is_branch = '/'.join(here_url.split('/')[:-1]) == here_root + '/branches' if not is_trunk and not is_branch: # command must be run at the "trunk" folder of a package output.error('Please run this command at the root of the package ' +\ '(trunk/branch folder)', exit=True) elif scm.is_git('.'): if not os.path.exists('.git'): output.error('Please run this command at the root of the package ' +\ 'checkout', exit=True) # .. other checks if not os.path.isfile('setup.py'): # setup.py is required output.error('Could not find the file ./setup.py', exit=True) if not os.path.isfile('docs/HISTORY.txt'): # docs/HISTORY.txt is required output.error('Could not find the file ./docs/HISTORY.txt', exit=True) if os.path.isfile('setup.cfg'): # setup.cfg is not necessary, it should not be used since the development # stuff makes bad distribution versions output.error('setup.cfg should not be used anymore') if input.prompt_bool('Should I delete setup.cfg?'): scm.remove_files('setup.cfg') scm.commit_files('Removed setup.cfg', 'setup.cfg') version_file = os.path.join(scm.get_package_name('.').replace('.', '/'), 'version.txt') if not os.path.isfile(version_file): # version.txt is required output.error('Could not find the file %s' % version_file, exit=True) # check MANIFEST.in self.check_manifest() # check subversion state if scm.has_local_changes('.'): output.error('You have local changes, please commit them first.', exit=True)