Skip to content
This repository was archived by the owner on Dec 19, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wit/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def print_errors(errors):

for err in errors:
log.info("--- ERROR ---")
log.info(err)
log.info(str(err))


class WitUserError(Exception):
Expand Down
15 changes: 11 additions & 4 deletions lib/wit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ def main() -> None:
update_dep_parser.add_argument('pkg', metavar='pkg[::revision]', type=parse_dependency_tag)

subparsers.add_parser('status', help='show status of workspace')
subparsers.add_parser('update', help='update git repos')

update_parser = subparsers.add_parser('update', help='update git repos')
update_parser.add_argument('--force', action='store_true', help='checkout regardless of errors')

inspect_parser = subparsers.add_parser('inspect', help='inspect lockfile')
inspect_group = inspect_parser.add_mutually_exclusive_group()
Expand Down Expand Up @@ -358,10 +360,15 @@ def status(ws, args) -> None:

def update(ws, args) -> None:
packages, errors = ws.resolve(download=True)
if len(errors) == 0:
ws.checkout(packages)
else:

# the errors assume the repos are still in .wit
if len(errors) > 0:
print_errors(errors)

if len(errors) == 0 or ('force' in args and args.force):
ws.checkout(packages)

if len(errors) > 0:
sys.exit(1)


Expand Down
70 changes: 70 additions & 0 deletions t/wit_ancestry_force.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/usr/bin/env bash

. $(dirname $0)/regress_util.sh

prereq "on"

make_repo 'xyz'

cd xyz
touch zero
git add -A
git commit -m "xyz:0"

git checkout -b branch_a
touch testa
git add -A
git commit -m "xyz:a"
xyz_commit_a=$(git rev-parse HEAD)

git checkout master

git checkout -b branch_b
touch testb
git add -A
git commit -m "xyz:b"
xyz_commit_b=$(git rev-parse HEAD)
cd ..

make_repo 'foo'
cat << EOF | jq . > foo/wit-manifest.json
[
{ "commit": "$xyz_commit_b", "name": "xyz", "source": "$PWD/xyz" }
]
EOF
git -C foo add -A
git -C foo commit -m "add xyz:2"
foo_commit=$(git -C foo rev-parse HEAD)

# Set up repo foo
make_repo 'bar'
cat << EOF | jq . > bar/wit-manifest.json
[
{ "commit": "$xyz_commit_a", "name": "xyz", "source": "$PWD/xyz" }
]
EOF
git -C bar add -A
git -C bar commit -m "add xyz:1"

prereq "off"

# Now create a workspace from main_repo
wit init myws -a $PWD/foo -a $PWD/bar

check "wit init should fail with AncestryError" [ $? -ne 0 ]

cd myws
wit update
check "wit update should fail with AncestryError" [ $? -ne 0 ]

ls foo || ls bar || ls xyz
check "repos should not be checked out" [ $? -ne 0 ]

wit update --force
check "wit update --force should return non-zero exit code" [ $? -ne 0 ]

ls foo && ls bar && ls xyz
check "repos should be checked out" [ $? -eq 0 ]

report
finish