diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/combo-layer | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 4029d2bff8..2d100bebdf 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
| @@ -29,6 +29,7 @@ import tempfile | |||
| 29 | import ConfigParser | 29 | import ConfigParser |
| 30 | import re | 30 | import re |
| 31 | from collections import OrderedDict | 31 | from collections import OrderedDict |
| 32 | from string import Template | ||
| 32 | 33 | ||
| 33 | __version__ = "0.2.1" | 34 | __version__ = "0.2.1" |
| 34 | 35 | ||
| @@ -77,15 +78,27 @@ class Configuration(object): | |||
| 77 | value = getattr(parser, 'get' + types[name])(section, name) | 78 | value = getattr(parser, 'get' + types[name])(section, name) |
| 78 | self.repos[repo][name] = value | 79 | self.repos[repo][name] = value |
| 79 | 80 | ||
| 81 | def readglobalsection(parser, section): | ||
| 82 | for (name, value) in parser.items(section): | ||
| 83 | if name == "commit_msg": | ||
| 84 | self.commit_msg_template = value | ||
| 85 | |||
| 80 | logger.debug("Loading config file %s" % self.conffile) | 86 | logger.debug("Loading config file %s" % self.conffile) |
| 81 | self.parser = ConfigParser.ConfigParser() | 87 | self.parser = ConfigParser.ConfigParser() |
| 82 | with open(self.conffile) as f: | 88 | with open(self.conffile) as f: |
| 83 | self.parser.readfp(f) | 89 | self.parser.readfp(f) |
| 84 | 90 | ||
| 91 | # initialize default values | ||
| 92 | self.commit_msg_template = "Automatic commit to update last_revision" | ||
| 93 | |||
| 85 | self.repos = {} | 94 | self.repos = {} |
| 86 | for repo in self.parser.sections(): | 95 | for repo in self.parser.sections(): |
| 87 | self.repos[repo] = {} | 96 | if repo == "combo-layer-settings": |
| 88 | readsection(self.parser, repo, repo) | 97 | # special handling for global settings |
| 98 | readglobalsection(self.parser, repo) | ||
| 99 | else: | ||
| 100 | self.repos[repo] = {} | ||
| 101 | readsection(self.parser, repo, repo) | ||
| 89 | 102 | ||
| 90 | # Load local configuration, if available | 103 | # Load local configuration, if available |
| 91 | self.localconffile = None | 104 | self.localconffile = None |
| @@ -715,7 +728,21 @@ def action_update(conf, args): | |||
| 715 | if output: | 728 | if output: |
| 716 | logger.info("Committing updated configuration file") | 729 | logger.info("Committing updated configuration file") |
| 717 | if output.lstrip().startswith("M"): | 730 | if output.lstrip().startswith("M"): |
| 718 | runcmd('git commit -m "Automatic commit to update last_revision" %s' % relpath) | 731 | |
| 732 | # create the "components" string | ||
| 733 | component_str = "all components" | ||
| 734 | if len(components) > 0: | ||
| 735 | # otherwise tell which components were actually changed | ||
| 736 | component_str = ", ".join(components) | ||
| 737 | |||
| 738 | # expand the template with known values | ||
| 739 | template = Template(conf.commit_msg_template) | ||
| 740 | raw_msg = template.substitute(components = component_str) | ||
| 741 | |||
| 742 | # sanitize the string before using it in command line | ||
| 743 | msg = raw_msg.replace('"', '\\"') | ||
| 744 | |||
| 745 | runcmd('git commit -m "%s" %s' % (msg, relpath)) | ||
| 719 | 746 | ||
| 720 | def apply_patchlist(conf, repos): | 747 | def apply_patchlist(conf, repos): |
| 721 | """ | 748 | """ |
