def detect_branches(self): with inbranch(self.src): if self.name is not None: return [self.name] package_data = get_package_data(self.src) if type(package_data) not in [list, tuple]: return package_data name, version, packages = package_data self.packages = packages return name if type(name) is list else [name]
def post_patch(self, destination): # Figure out the version of the given package with inbranch(destination): package_data = get_package_data(destination) if type(package_data) not in [list, tuple]: return package_data name, version, packages = package_data # Execute git tag execute_command('git tag -f ' + destination + '/' + version) return 0
def detect_branches(self): self.packages = None with inbranch(self.src): if self.name is not None: self.packages = [self.name] return [self.name] name, version, packages = get_package_data(self.src) self.packages = packages # Check meta packages for valid CMakeLists.txt if isinstance(self.packages, dict): for path, pkg in self.packages.iteritems(): # Check for valid CMakeLists.txt if a metapackage self.metapackage_check(path, pkg) return name if type(name) is list else [name]
def post_patch(self, destination): # Figure out the version of the given package if self.name is not None: warning("""\ Cannot automatically tag the release because this is not a catkin project.""") warning("""\ Please checkout the release branch and then create a tag manually with:""") warning(" git checkout release/" + str(self.name)) warning(" git tag -f release/" + str(self.name) + "/<version>") return with inbranch(destination): name, version, packages = get_package_data(destination) # Execute git tag release_tag = destination + '/' + version + '-' + self.release_inc execute_command('git tag ' + release_tag)
def post_patch(self, destination): # Figure out the version of the given package if self.name is not None: warning("Cannot automatically tag the release because this is " "not a catkin project. Please create a tag manually with:") warning(" git tag -f release/" + str(self.name) + "/<version>") return 0 with inbranch(destination): package_data = get_package_data(destination) if type(package_data) not in [list, tuple]: return package_data name, version, packages = package_data # Execute git tag execute_command('git tag -f ' + destination + '/' + version) return 0
def detect_branches(self): self.packages = None with inbranch(self.src): if self.name is not None: self.packages = [self.name] return [self.name] name, version, packages = get_package_data(self.src) self.packages = packages # Check meta packages for valid CMakeLists.txt if isinstance(self.packages, dict): for path, pkg in self.packages.iteritems(): with change_directory(path): if is_metapackage(pkg): check_metapackage_for_valid_cmake(pkg.name) return name if type(name) is list else [name]
def get_stackage_from_branch(branch): with inbranch(branch): package_data = get_package_data(branch) if type(package_data) not in [list, tuple]: # It is a ret code DebianGenerator.exit(package_data) name, version, packages = package_data if type(name) is list and len(name) > 1: error("Debian generator does not support generating " "from branches with multiple packages in them, use " "the release generator first to split packages into " "individual branches.") DebianGenerator.exit(code.DEBIAN_MULTIPLE_PACKAGES_FOUND) if type(packages) is dict: return packages.values()[0], 'package' return packages, 'stack'
def get_upstream_meta(upstream_dir, ros_distro): meta = None with change_directory(upstream_dir): if get_root() is not None: # If in a git repo current_branch = get_current_branch() else: current_branch = None name, version, stackages = get_package_data( current_branch, quiet=False, fuerte=(ros_distro == 'fuerte')) meta = { 'name': name, 'version': version, 'type': 'package.xml' if isinstance(stackages, dict) else 'stack.xml' } return meta
def detect_branches(self): self.packages = None with inbranch(self.src): if self.name is not None: self.packages = [self.name] return [self.name] package_data = get_package_data( self.src, fuerte=(self.rosdistro == 'fuerte')) if type(package_data) not in [list, tuple]: return package_data name, version, packages = package_data self.packages = packages # Check meta packages for valid CMakeLists.txt if isinstance(self.packages, dict): for path, pkg in self.packages.iteritems(): # Check for valid CMakeLists.txt if a metapackage self.metapackage_check(path, pkg) return name if type(name) is list else [name]
def non_git_rebase(upstream_branch, directory=None): # Create a temporary storage directory tmp_dir = mkdtemp() # Get the root of the git repository git_root = get_root(directory) try: # Copy the new upstream source into the temporary directory with inbranch(upstream_branch): ignores = ('.git', '.gitignore', '.svn', '.hgignore', '.hg', 'CVS') parent_source = os.path.join(tmp_dir, 'parent_source') try: # Try catch this to handle dangling symbolic links # See: http://bugs.python.org/issue6547 shutil.copytree(git_root, parent_source, ignore=shutil.ignore_patterns(*ignores)) except shutil.Error as e: for src, dst, error in e.args[0]: if not os.path.islink(src): raise else: linkto = os.readlink(src) if os.path.exists(linkto): raise # dangling symlink found.. ignoring.. # Clear out the local branch execute_command('git rm -rf *', cwd=directory) # Collect .* files (excluding .git) dot_items = [] for item in os.listdir(git_root): if item in ['.git', '..', '.']: continue if item.startswith('.'): dot_items.append(item) # Remove and .* files missed by 'git rm -rf *' if len(dot_items) > 0: execute_command('git rm -rf ' + ' '.join(dot_items), cwd=directory) # Clear out any untracked files execute_command('git clean -fdx', cwd=directory) # for good measure? # Copy the parent source into the newly cleaned directory for item in os.listdir(parent_source): src = os.path.join(parent_source, item) dst = os.path.join(git_root, item) if os.path.isdir(src): shutil.copytree(src, dst) else: shutil.copy(src, dst) # Commit changes to the repository execute_command('git add ./*', cwd=directory) # Collect .* files dot_items = [] for item in os.listdir(git_root): if item in ['.git', '..', '.']: continue if item.startswith('.'): dot_items.append(item) # Add any .* files missed by 'git add ./*' if len(dot_items) > 0: execute_command('git add ' + ' '.join(dot_items), cwd=directory) # Remove any straggling untracked files execute_command('git clean -dXf', cwd=directory) # Only if we have local changes commit # (not true if the upstream didn't change any files) if has_changes(directory): cmd = 'git commit -m "Rebase from \'' + upstream_branch + "'" data = get_package_data(upstream_branch, quiet=True) if type(data) in [list, tuple]: cmd += " @ version '{0}'".format(data[1]) cmd += '"' execute_command(cmd, cwd=directory) finally: # Clean up if os.path.exists(tmp_dir): shutil.rmtree(tmp_dir)