def _get_instructions(cls, comments, old_version, new_version): """Extract instructions from comments, update version if necessary""" instructions = [] for comment in comments: comment = MacroHelper.expand(comment, comment) comment = MacroHelper.expand(comment, comment) comment = re.sub(r'^#\s*', '', comment) comment = comment.replace(old_version, new_version) instructions.append(comment) return instructions
def generate_patch(self): """ Generates patch to the results_dir containing all needed changes for the rebased package version """ # Delete removed patches from rebased_sources_dir from git removed_patches = self.rebase_spec_file.removed_patches if removed_patches: self.rebased_repo.index.remove(removed_patches, working_tree=True) self.rebase_spec_file.update_paths_to_patches() # Generate patch self.rebased_repo.git.add(all=True) self.rebase_spec_file._update_data() # pylint: disable=protected-access self.rebased_repo.index.commit(MacroHelper.expand(self.conf.changelog_entry, self.conf.changelog_entry)) patch = self.rebased_repo.git.format_patch('-1', stdout=True, stdout_as_string=False) with open(os.path.join(self.results_dir, 'changes.patch'), 'wb') as f: f.write(patch) f.write(b'\n') results_store.set_changes_patch('changes_patch', os.path.join(self.results_dir, 'changes.patch'))