diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-09-29 16:56:20 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-11-11 12:14:27 +0000 |
commit | fe85a2a8b4adb9671ad308e75fc3d1f2c5e08916 (patch) | |
tree | 788a3b438f73f23dd7d09fdb94e9a020d42014a1 /scripts/lib/devtool/__init__.py | |
parent | d5ffd41a93b7ccacca9ab997d9918920485c27a9 (diff) | |
download | poky-fe85a2a8b4adb9671ad308e75fc3d1f2c5e08916.tar.gz |
devtool: finish: ensure repository is clean before proceeding
If the git repository for a recipe in the workspace has uncommitted
changes in it then it's possible that the user has forgotten to commit
something, so check and exit if there are any. Provide a -f/--force
option to continue in the case where the uncommitted changes aren't
needed.
Separately, if the repository is in the middle of a rebase or git am /
apply then error out (without the opportunity to force) since the user
really needs to sort this out before finishing.
(From OE-Core rev: bfebd18982c0c82ef2da63ec8f22175c93b2e308)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/devtool/__init__.py')
-rw-r--r-- | scripts/lib/devtool/__init__.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/lib/devtool/__init__.py b/scripts/lib/devtool/__init__.py index 20ab83f83d..07d774dfb7 100644 --- a/scripts/lib/devtool/__init__.py +++ b/scripts/lib/devtool/__init__.py | |||
@@ -350,3 +350,20 @@ def check_prerelease_version(ver, operation): | |||
350 | 'If you prefer not to reset and re-try, you can change ' | 350 | 'If you prefer not to reset and re-try, you can change ' |
351 | 'the version after %s succeeds using "devtool rename" ' | 351 | 'the version after %s succeeds using "devtool rename" ' |
352 | 'with -V/--version.' % (ver, operation)) | 352 | 'with -V/--version.' % (ver, operation)) |
353 | |||
354 | def check_git_repo_dirty(repodir): | ||
355 | """Check if a git repository is clean or not""" | ||
356 | stdout, _ = bb.process.run('git status --porcelain', cwd=repodir) | ||
357 | return stdout | ||
358 | |||
359 | def check_git_repo_op(srctree, ignoredirs=None): | ||
360 | """Check if a git repository is in the middle of a rebase""" | ||
361 | stdout, _ = bb.process.run('git rev-parse --show-toplevel', cwd=srctree) | ||
362 | topleveldir = stdout.strip() | ||
363 | if ignoredirs and topleveldir in ignoredirs: | ||
364 | return | ||
365 | gitdir = os.path.join(topleveldir, '.git') | ||
366 | if os.path.exists(os.path.join(gitdir, 'rebase-merge')): | ||
367 | raise DevtoolError("Source tree %s appears to be in the middle of a rebase - please resolve this first" % srctree) | ||
368 | if os.path.exists(os.path.join(gitdir, 'rebase-apply')): | ||
369 | raise DevtoolError("Source tree %s appears to be in the middle of 'git am' or 'git apply' - please resolve this first" % srctree) | ||