devtool: add: set up fetched source as a git repository by default

If the fetched source isn't already a git repository, initialise it as
one and then branch and tag, just as we do with "devtool modify". This
makes it easier to make changes, commit them and then use the
"devtool update-recipe" command to turn those commits into patches
on the recipe.

(From OE-Core rev: 2dd865086c37c9eff63c6d0bbfa9f2e909f9fffe)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Eggleton authored and Richard Purdie committed 2015-09-23 09:53:17 +01:00
1 parent e759b0b75d
commit 3bd0f33505
2 files changed
+23 -7

No files matched your search

+17
View File
@@ -170,3 +170,20 @@ def use_external_build(same_dir, no_same_dir, d):
else:
b_is_s = False
return b_is_s
def setup_git_repo(repodir, version, devbranch, basetag='devtool-base'):
"""
Set up the git repository for the source tree
"""
import bb.process
if not os.path.exists(os.path.join(repodir, '.git')):
bb.process.run('git init', cwd=repodir)
bb.process.run('git add .', cwd=repodir)
if version:
commitmsg = "Initial commit from upstream at version %s" % version
else:
commitmsg = "Initial commit from upstream"
bb.process.run('git commit -q -m "%s"' % commitmsg, cwd=repodir)
bb.process.run('git checkout -b %s' % devbranch, cwd=repodir)
bb.process.run('git tag -f %s' % basetag, cwd=repodir)