diff options
Diffstat (limited to 'scripts/combo-layer')
-rwxr-xr-x | scripts/combo-layer | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/combo-layer b/scripts/combo-layer index 6d24ce3ee1..cbff61803b 100755 --- a/scripts/combo-layer +++ b/scripts/combo-layer | |||
@@ -284,6 +284,46 @@ def action_init(conf, args): | |||
284 | runcmd("git branch -D %s" % refname, ldir) | 284 | runcmd("git branch -D %s" % refname, ldir) |
285 | # Make that the head revision. | 285 | # Make that the head revision. |
286 | runcmd("git checkout -b %s %s" % (name, initialrev)) | 286 | runcmd("git checkout -b %s %s" % (name, initialrev)) |
287 | # Optional: cut the history by replacing the given | ||
288 | # start point(s) with commits providing the same | ||
289 | # content (aka tree), but with commit information that | ||
290 | # makes it clear that this is an artifically created | ||
291 | # commit and nothing the original authors had anything | ||
292 | # to do with. | ||
293 | since_rev = repo.get('since_revision', '') | ||
294 | if since_rev: | ||
295 | committer = runcmd('git var GIT_AUTHOR_IDENT').strip() | ||
296 | # Same time stamp, no name. | ||
297 | author = re.sub('.* (\d+ [+-]\d+)', r'unknown <unknown> \1', committer) | ||
298 | logger.info('author %s' % author) | ||
299 | for rev in since_rev.split(): | ||
300 | # Resolve in component repo... | ||
301 | rev = runcmd('git log --oneline --no-abbrev-commit -n1 %s' % rev, ldir).split()[0] | ||
302 | # ... and then get the tree in current | ||
303 | # one. The commit should be in both repos with | ||
304 | # the same tree, but better check here. | ||
305 | tree = runcmd('git show -s --pretty=format:%%T %s' % rev).strip() | ||
306 | with tempfile.NamedTemporaryFile() as editor: | ||
307 | editor.write('''cat >$1 <<EOF | ||
308 | tree %s | ||
309 | author %s | ||
310 | committer %s | ||
311 | |||
312 | %s: squashed import of component | ||
313 | |||
314 | This commit copies the entire set of files as found in | ||
315 | %s %s | ||
316 | |||
317 | For more information about previous commits, see the | ||
318 | upstream repository. | ||
319 | |||
320 | Commit created by combo-layer. | ||
321 | EOF | ||
322 | ''' % (tree, author, committer, name, name, since_rev)) | ||
323 | editor.flush() | ||
324 | os.environ['GIT_EDITOR'] = 'sh %s' % editor.name | ||
325 | runcmd('git replace --edit %s' % rev) | ||
326 | |||
287 | # Optional: rewrite history to change commit messages or to move files. | 327 | # Optional: rewrite history to change commit messages or to move files. |
288 | if 'hook' in repo or dest_dir and dest_dir != ".": | 328 | if 'hook' in repo or dest_dir and dest_dir != ".": |
289 | filter_branch = ['git', 'filter-branch', '--force'] | 329 | filter_branch = ['git', 'filter-branch', '--force'] |