@@ -1581,6 +1581,45 @@ def new_branch_github(paths, ecs, commit_msg=None):
15811581 return res
15821582
15831583
1584+ def det_pr_title (ecs ):
1585+ """
1586+ Create title for PR based on first easyconfigs
1587+ :param ecs: list of parsed easyconfigs
1588+ """
1589+
1590+ # only use most common toolchain(s) in toolchain label of PR title
1591+ toolchains = ['%(name)s/%(version)s' % ec ['toolchain' ] for ec in ecs ]
1592+ toolchains_counted = sorted ([(toolchains .count (tc ), tc ) for tc in nub (toolchains )])
1593+ toolchain_label = ',' .join ([tc for (cnt , tc ) in toolchains_counted if cnt == toolchains_counted [- 1 ][0 ]])
1594+
1595+ # only use most common module class(es) in moduleclass label of PR title
1596+ classes = [ec ['moduleclass' ] for ec in ecs ]
1597+ classes_counted = sorted ([(classes .count (c ), c ) for c in nub (classes )])
1598+ class_label = ',' .join ([tc for (cnt , tc ) in classes_counted if cnt == classes_counted [- 1 ][0 ]])
1599+
1600+ names_and_versions = nub (["%s v%s" % (ec .name , ec .version ) for ec in ecs ])
1601+ if len (names_and_versions ) <= 3 :
1602+ main_title = ', ' .join (names_and_versions )
1603+ else :
1604+ main_title = ', ' .join (names_and_versions [:3 ] + ['...' ])
1605+
1606+ title = "{%s}[%s] %s" % (class_label , toolchain_label , main_title )
1607+
1608+ # Find all suffixes
1609+ suffixes = []
1610+ for ec in ecs :
1611+ if 'versionsuffix' in ec and ec ['versionsuffix' ]:
1612+ suffixes .append (ec ['versionsuffix' ].strip ('-' ).replace ('-' , ' ' ))
1613+ if suffixes :
1614+ suffixes = sorted (nub (suffixes ))
1615+ if len (suffixes ) <= 2 :
1616+ title += ' w/ ' + ', ' .join (suffixes )
1617+ else :
1618+ title += ' w/ ' + ', ' .join (suffixes [:2 ] + ['...' ])
1619+
1620+ return title
1621+
1622+
15841623@only_if_module_is_available ('git' , pkgname = 'GitPython' )
15851624def new_pr_from_branch (branch_name , title = None , descr = None , pr_target_repo = None , pr_metadata = None , commit_msg = None ):
15861625 """
@@ -1691,42 +1730,10 @@ def new_pr_from_branch(branch_name, title=None, descr=None, pr_target_repo=None,
16911730
16921731 labels = det_pr_labels (file_info , pr_target_repo )
16931732
1694- if pr_target_repo == GITHUB_EASYCONFIGS_REPO :
1695- # only use most common toolchain(s) in toolchain label of PR title
1696- toolchains = ['%(name)s/%(version)s' % ec ['toolchain' ] for ec in file_info ['ecs' ]]
1697- toolchains_counted = sorted ([(toolchains .count (tc ), tc ) for tc in nub (toolchains )])
1698- toolchain_label = ',' .join ([tc for (cnt , tc ) in toolchains_counted if cnt == toolchains_counted [- 1 ][0 ]])
1699-
1700- # only use most common module class(es) in moduleclass label of PR title
1701- classes = [ec ['moduleclass' ] for ec in file_info ['ecs' ]]
1702- classes_counted = sorted ([(classes .count (c ), c ) for c in nub (classes )])
1703- class_label = ',' .join ([tc for (cnt , tc ) in classes_counted if cnt == classes_counted [- 1 ][0 ]])
1704-
17051733 if title is None :
17061734 if pr_target_repo == GITHUB_EASYCONFIGS_REPO :
17071735 if file_info ['ecs' ] and all (file_info ['new' ]) and not deleted_paths :
1708- # mention software name/version in PR title (only first 3)
1709- names_and_versions = nub (["%s v%s" % (ec .name , ec .version ) for ec in file_info ['ecs' ]])
1710- if len (names_and_versions ) <= 3 :
1711- main_title = ', ' .join (names_and_versions )
1712- else :
1713- main_title = ', ' .join (names_and_versions [:3 ] + ['...' ])
1714-
1715- title = "{%s}[%s] %s" % (class_label , toolchain_label , main_title )
1716-
1717- # if Python is listed as a dependency, then mention Python version(s) in PR title
1718- pyver = []
1719- for ec in file_info ['ecs' ]:
1720- # iterate over all dependencies (incl. build dependencies & multi-deps)
1721- for dep in ec .dependencies ():
1722- if dep ['name' ] == 'Python' :
1723- # check whether Python is listed as a multi-dep if it's marked as a build dependency
1724- if dep ['build_only' ] and 'Python' not in ec ['multi_deps' ]:
1725- continue
1726- else :
1727- pyver .append (dep ['version' ])
1728- if pyver :
1729- title += " w/ Python %s" % ' + ' .join (sorted (nub (pyver )))
1736+ title = det_pr_title (file_info ['ecs' ])
17301737 elif pr_target_repo == GITHUB_EASYBLOCKS_REPO :
17311738 if file_info ['eb_names' ] and all (file_info ['new' ]) and not deleted_paths :
17321739 plural = 's' if len (file_info ['eb_names' ]) > 1 else ''
0 commit comments