summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-03-06 22:13:11 +0200
committerLars Wirzenius <liw@liw.fi>2016-03-06 22:13:11 +0200
commitb0ab0be773938324d74c56d060ae191a28b808dd (patch)
tree8e8126fbd006379a0e69915c841fea060a402ff8
parent06099ec1fa89c30b41662666d1b1cdcdd64a82e9 (diff)
downloadick-b0ab0be773938324d74c56d060ae191a28b808dd.tar.gz
Move {Load,Save}ProjectInfo into separate module
-rw-r--r--icklib/__init__.py1
-rw-r--r--icklib/project.py51
-rw-r--r--icklib/step_project_info.py56
-rw-r--r--without-tests1
4 files changed, 66 insertions, 43 deletions
diff --git a/icklib/__init__.py b/icklib/__init__.py
index bf04a7b..6a153f1 100644
--- a/icklib/__init__.py
+++ b/icklib/__init__.py
@@ -23,6 +23,7 @@ from .build_step import BuildStep
from .run_state import RunState
from .pipeline import BuildPipeline
from .os_release import parse_os_release, OsRelease, NoOsReleaseInformation
+from .step_project_info import LoadProjectInfo, SaveProjectInfo
from .project import create_projects_from_ick
from .git import GitClone
from .info import InformationStore
diff --git a/icklib/project.py b/icklib/project.py
index e9b3b5c..d8f6570 100644
--- a/icklib/project.py
+++ b/icklib/project.py
@@ -223,41 +223,6 @@ class Project(object):
remote_git_dir)
-class LoadProjectInfo(icklib.BuildStep):
-
- def build(self):
- self.run_state.progress['step'] = 'Loading project state'
- self.run_state.logger.important('Loading project state')
- self.run_state.project_info = icklib.ProjectInformation()
-
- filename = self.statedir.get_project_state_path(self.project.name)
- self.run_state.project_info.set_filename(filename)
- dirname = os.path.dirname(filename)
-
- if not os.path.exists(dirname):
- os.makedirs(dirname)
- if os.path.exists(filename):
- self.run_state.project_info.load()
-
- if self.run_state.project_info.built_commits is None:
- self.run_state.project_info.built_commits = {}
-
-
-class SaveProjectInfo(icklib.BuildStep):
-
- def build(self):
- self.run_state.progress['step'] = 'Saving project state'
- self.run_state.logger.important('Saving project state')
-
- if hasattr(self.run_state, 'commits'):
- value = self.run_state.commits
- if value is not None:
- key = self.run_state.pipeline.name
- self.run_state.project_info.built_commits[key] = value
-
- self.run_state.project_info.save()
-
-
class CloneGits(icklib.BuildStep):
def build(self):
@@ -1116,27 +1081,27 @@ class LineLogger(object): # pragma: no cover
def create_projects_from_ick(ick, wanted_names):
pipelines = {
'shell': [
- LoadProjectInfo,
+ icklib.LoadProjectInfo,
CloneGits,
FindCurrentGitCommits,
FindNewCommitToBuildForShell,
CreateBuildInfo,
RunShellCommandsOnEachTarget,
FinishBuildInfo,
- SaveProjectInfo,
+ icklib.SaveProjectInfo,
],
'local-shell': [
- LoadProjectInfo,
+ icklib.LoadProjectInfo,
CloneGits,
FindCurrentGitCommits,
FindNewCommitToBuildForLocalShell,
CreateBuildInfo,
RunLocalShellCommands,
FinishBuildInfo,
- SaveProjectInfo,
+ icklib.SaveProjectInfo,
],
'debian-ci': [
- LoadProjectInfo,
+ icklib.LoadProjectInfo,
CloneGits,
FindCurrentGitCommits,
FindNewCommitToBuildForDebianCI,
@@ -1149,10 +1114,10 @@ def create_projects_from_ick(ick, wanted_names):
SetupAPTRepository,
UploadDebianPackagesToCIRepo,
FinishBuildInfo,
- SaveProjectInfo,
+ icklib.SaveProjectInfo,
],
'debian-release': [
- LoadProjectInfo,
+ icklib.LoadProjectInfo,
CloneGits,
FindCurrentGitCommits,
FindTagsToBuildForDebianRelease,
@@ -1166,7 +1131,7 @@ def create_projects_from_ick(ick, wanted_names):
UploadDebianPackagesToCIRepo,
PublishDebianPackages,
FinishBuildInfo,
- SaveProjectInfo,
+ icklib.SaveProjectInfo,
],
}
diff --git a/icklib/step_project_info.py b/icklib/step_project_info.py
new file mode 100644
index 0000000..bceabf4
--- /dev/null
+++ b/icklib/step_project_info.py
@@ -0,0 +1,56 @@
+# 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 os
+
+import icklib
+
+
+class LoadProjectInfo(icklib.BuildStep):
+
+ def build(self):
+ self.run_state.progress['step'] = 'Loading project state'
+ self.run_state.logger.important('Loading project state')
+ self.run_state.project_info = icklib.ProjectInformation()
+
+ filename = self.statedir.get_project_state_path(self.project.name)
+ self.run_state.project_info.set_filename(filename)
+ dirname = os.path.dirname(filename)
+
+ if not os.path.exists(dirname):
+ os.makedirs(dirname)
+ if os.path.exists(filename):
+ self.run_state.project_info.load()
+
+ if self.run_state.project_info.built_commits is None:
+ self.run_state.project_info.built_commits = {}
+
+
+class SaveProjectInfo(icklib.BuildStep):
+
+ def build(self):
+ self.run_state.progress['step'] = 'Saving project state'
+ self.run_state.logger.important('Saving project state')
+
+ if hasattr(self.run_state, 'commits'):
+ value = self.run_state.commits
+ if value is not None:
+ key = self.run_state.pipeline.name
+ self.run_state.project_info.built_commits[key] = value
+
+ self.run_state.project_info.save()
diff --git a/without-tests b/without-tests
index cf75ea5..bff94bf 100644
--- a/without-tests
+++ b/without-tests
@@ -4,3 +4,4 @@ icklib/project.py
icklib/info.py
icklib/version.py
icklib/progress.py
+icklib/step_project_info.py