def printFetchCommands(packageList, asSubModule=True): """ Prints the VCS fetch command for each package in the list. Duplicates will be removed, and output will be sorted for better readability, e.g.: asSubModule = True: git submodule add [email protected]:TECH_Team/BPL.git git submodule add [email protected]:ToolBOS/BasicComponents.git git submodule add [email protected]:ToolBOS/ToolBOSLib.git asSubModule = False: git clone [email protected]:TECH_Team/BPL.git git clone [email protected]:ToolBOS/BasicComponents.git git clone [email protected]:ToolBOS/ToolBOSLib.git """ Any.requireIsIterable(packageList) Any.requireIsBool(asSubModule) sitRootPath = SIT.getRootPath() commands = set() # avoids duplicates for canonicalPath in packageList: ProjectProperties.requireIsCanonicalPath(canonicalPath) installRoot = os.path.join(sitRootPath, canonicalPath) Any.requireIsExisting(installRoot) detector = PackageDetector.PackageDetector(installRoot) detector.retrieveMetaInfoFromSIT() vcsRoot = detector.vcsRoot if vcsRoot: Any.requireIsTextNonEmpty(vcsRoot) repo = VersionControl.auto(vcsRoot) if isinstance(repo, SVN.SVNRepository): repo.setConfiguredUserName() command = repo.getSourceCodeCommand() elif isinstance(repo, Git.RemoteGitRepository): command = repo.getSourceCodeCommand(asSubModule) else: raise TypeError('unexpected datatype: %s', type(repo)) else: command = '# VCS location unknown: %s' % canonicalPath commands.add(command) for command in sorted(commands): print(command)
def printBuildCommands(orderedList): """ Prints the build-instruction for each package in the list, e.g.: build src/ToolBOSCore build src/ToolBOSLib build src/IniConfigFile build src/Middleware Note: The list shall already be sorted according to build order! """ Any.requireIsListNonEmpty(orderedList) sitRootPath = SIT.getRootPath() commands = [] for canonicalPath in orderedList: ProjectProperties.requireIsCanonicalPath(canonicalPath) installRoot = os.path.join(sitRootPath, canonicalPath) Any.requireIsExisting(installRoot) detector = PackageDetector.PackageDetector(installRoot) detector.retrieveMetaInfoFromSIT() vcsRelPath = detector.vcsRelPath vcsRoot = detector.vcsRoot if vcsRoot: Any.requireIsTextNonEmpty(vcsRoot) repo = VersionControl.auto(vcsRoot) repoName = repo.getRepositoryName() if vcsRelPath: location = os.path.join('src', repoName, vcsRelPath) else: location = os.path.join('src', repoName) command = 'build %s' % location else: command = '# build %s# location unknown' % canonicalPath.ljust(70) commands.append(command) for command in commands: print(command)