30
30
all_platform_sdk_list = list (map (lambda plat : plat ["plat_name" ], ALL_PLATFORM_SDK ))
31
31
32
32
33
- def clean_sdk (sdk_target_location ):
33
+ def clean_sdk_local_changes (sdk_target_location ):
34
34
print ("SDK will be cleaned all local modification(s) will be lost" )
35
35
# Cleaning all local modifications
36
36
git_clean_command = "git reset --hard && git clean -xdf"
37
37
command = ['west' , 'forall' , '-c' , git_clean_command , '-a' ]
38
38
subprocess .run (command , cwd = sdk_target_location , check = True )
39
- # Retrying an update
40
- update_platform_sdk_version (sdk_target_location , False )
41
39
42
40
43
41
def init_platform_sdk_version (sdk_target_location , force ):
@@ -64,7 +62,11 @@ def update_platform_sdk_version(sdk_target_location, force):
64
62
subprocess .run (command , cwd = sdk_target_location , check = True )
65
63
except (RuntimeError , subprocess .CalledProcessError ) as exception :
66
64
if force :
67
- clean_sdk (sdk_target_location )
65
+ # In case of force update option and in case of update failure:
66
+ # 1. try to clean all local modications if any
67
+ # 2. Retry the west update command. It should be successfull now as all local modifications have been cleaned
68
+ clean_sdk_local_changes (sdk_target_location )
69
+ subprocess .run (command , cwd = sdk_target_location , check = True )
68
70
else :
69
71
print (exception )
70
72
print ("Error SDK cannot be updated, local changes should be cleaned manually or use --force to force update" )
0 commit comments