@@ -651,27 +651,17 @@ def get_idf_version(idf_path):
651651
652652
653653def get_idf_ver_dir (idf_path , component_path ):
654- try :
655- # Run `git describe` inside the IDF_PATH directory
656- result = subprocess .run (
657- ['git' , 'describe' , '--tags' , '--dirty' ],
658- cwd = idf_path ,
659- capture_output = True ,
660- text = True ,
661- check = True
662- )
663- idf_ver = result .stdout .strip ()
664- except subprocess .CalledProcessError :
665- raise RuntimeError ('Failed to retrieve IDF version using `git describe`.' )
666- # Regex to match version tags like vX.Y or vX.Y.Z (with optional -dirty)
667- match = re .match (r'^(v\d+\.\d+(\.\d+)?)(-dirty)?$' , idf_ver )
654+ # Get the IDF version using the existing function
655+ idf_version = get_idf_version (idf_path )
668656
669- if match and os .path .isdir (os .path .join (component_path , f'idf_tag_{ match .group (1 )} ' )):
670- return f'idf_tag_{ match .group (1 )} ' # Return the clean tag (without -dirty)
671- idf_version = os .getenv ('ESP_IDF_VERSION' )
672- if idf_version is None :
673- raise RuntimeError ("Environment variable 'ESP_IDF_VERSION' wasn't set." )
674- return f'idf_v{ idf_version } '
657+ # Try exact tag version first (idf_tag_vX.Y.Z)
658+ tag_dir = f'idf_tag_v{ idf_version } '
659+ if os .path .isdir (os .path .join (component_path , tag_dir )):
660+ return tag_dir
661+
662+ # Fall back to branch version (idf_vX.Y)
663+ major , minor , _ = idf_version .split ('.' )
664+ return f'idf_v{ major } .{ minor } '
675665
676666
677667if __name__ == '__main__' :
0 commit comments