diff options
author | Lars Wirzenius <liw@liw.fi> | 2016-03-06 22:27:43 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2016-03-06 22:27:43 +0200 |
commit | 1d5c6fef9dbb28a8b28b3a26e00d115e7e13a46b (patch) | |
tree | df2c58bc9f8e3c25cbfdd7224bb1ad2dc2ffaf97 | |
parent | adca6c6c1b5b4e3ae7841920c3eab37c5e6f7228 (diff) | |
download | ick-1d5c6fef9dbb28a8b28b3a26e00d115e7e13a46b.tar.gz |
Move FindTagsToBuildForDebianRelease into module
-rw-r--r-- | icklib/__init__.py | 1 | ||||
-rw-r--r-- | icklib/project.py | 44 | ||||
-rw-r--r-- | icklib/step_find_tags_debian_release.py | 65 | ||||
-rw-r--r-- | without-tests | 1 |
4 files changed, 68 insertions, 43 deletions
diff --git a/icklib/__init__.py b/icklib/__init__.py index e88b5e0..793ac4b 100644 --- a/icklib/__init__.py +++ b/icklib/__init__.py @@ -30,6 +30,7 @@ from .step_find_new_commit import ( FindNewCommitToBuildForLocalShell, FindNewCommitToBuildForDebianCI, ) +from .step_find_tags_debian_release import FindTagsToBuildForDebianRelease from .step_git_clone import CloneGits from .step_project_info import LoadProjectInfo, SaveProjectInfo from .project import create_projects_from_ick diff --git a/icklib/project.py b/icklib/project.py index 27a5e73..46043a6 100644 --- a/icklib/project.py +++ b/icklib/project.py @@ -223,48 +223,6 @@ class Project(object): remote_git_dir) -class FindTagsToBuildForDebianRelease(icklib.BuildStep): - - def build(self): - tags = self._find_tags_in_repo( - self.project.name, self.run_state.clones[0]) - seen_tags = self.run_state.project_info.seen_tags - - if seen_tags is not None: - not_seen_tags = [x for x in tags if x not in seen_tags] - self.run_state.build_tags_using_debian_release = not_seen_tags - if self.run_state.build_tags_using_debian_release: - self.run_state.logger.important( - 'Need to build the following release tags:') - for tag in self.run_state.build_tags_using_debian_release: - self.run_state.logger.important(' {tag}', tag=tag) - else: - self.run_state.logger.important('No new release tags') - else: - self.run_state.logger.important( - 'Not seen this project before, so not building release') - self.run_state.logger.important( - 'Remembering existing release tags for future runs') - self.run_state.build_tags_using_debian_release = [] - - self.run_state.collect_debian_info = ( - self.run_state.build_tags_using_debian_release != []) - self.run_state.project_info.seen_tags = tags - - def _find_tags_in_repo(self, project_name, clone): - output = cliapp.runcmd(['git', 'tag', '-l'], cwd=clone.dirname) - return [ - tag for tag in output.splitlines() - if self._is_release_tag(project_name, tag)] - - def _is_release_tag(self, project_name, tag): - prefix = project_name + '-' - if not tag.startswith(prefix): - return False - pattern = r'^\d+\.\d+(\.\d+)*$' - return re.match(pattern, tag[len(prefix):]) - - class RunShellCommandsOnEachTarget(icklib.BuildStep): def build(self): @@ -957,7 +915,7 @@ def create_projects_from_ick(ick, wanted_names): icklib.LoadProjectInfo, icklib.CloneGits, icklib.FindCurrentGitCommits, - FindTagsToBuildForDebianRelease, + icklib.FindTagsToBuildForDebianRelease, icklib.CreateBuildInfo, CollectDebianInfoAboutTargets, CreateReleaseTarballs, diff --git a/icklib/step_find_tags_debian_release.py b/icklib/step_find_tags_debian_release.py new file mode 100644 index 0000000..747b30f --- /dev/null +++ b/icklib/step_find_tags_debian_release.py @@ -0,0 +1,65 @@ +# Copyright 2016 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +# =*= License: GPL-3+ =*= + + +import re + +import cliapp + +import icklib + + +class FindTagsToBuildForDebianRelease(icklib.BuildStep): + + def build(self): + tags = self._find_tags_in_repo( + self.project.name, self.run_state.clones[0]) + seen_tags = self.run_state.project_info.seen_tags + + if seen_tags is not None: + not_seen_tags = [x for x in tags if x not in seen_tags] + self.run_state.build_tags_using_debian_release = not_seen_tags + if self.run_state.build_tags_using_debian_release: + self.run_state.logger.important( + 'Need to build the following release tags:') + for tag in self.run_state.build_tags_using_debian_release: + self.run_state.logger.important(' {tag}', tag=tag) + else: + self.run_state.logger.important('No new release tags') + else: + self.run_state.logger.important( + 'Not seen this project before, so not building release') + self.run_state.logger.important( + 'Remembering existing release tags for future runs') + self.run_state.build_tags_using_debian_release = [] + + self.run_state.collect_debian_info = ( + self.run_state.build_tags_using_debian_release != []) + self.run_state.project_info.seen_tags = tags + + def _find_tags_in_repo(self, project_name, clone): + output = cliapp.runcmd(['git', 'tag', '-l'], cwd=clone.dirname) + return [ + tag for tag in output.splitlines() + if self._is_release_tag(project_name, tag)] + + def _is_release_tag(self, project_name, tag): + prefix = project_name + '-' + if not tag.startswith(prefix): + return False + pattern = r'^\d+\.\d+(\.\d+)*$' + return re.match(pattern, tag[len(prefix):]) diff --git a/without-tests b/without-tests index e60438b..7c321f2 100644 --- a/without-tests +++ b/without-tests @@ -7,5 +7,6 @@ icklib/progress.py icklib/step_build_info.py icklib/step_find_current_commit.py icklib/step_find_new_commit.py +icklib/step_find_tags_debian_release.py icklib/step_git_clone.py icklib/step_project_info.py |