def _print_diff(self, global_config, package_name, version, full_project_dir, relative_project_dir): """ Print a diff between the most recent package tag and HEAD, if necessary. """ last_tag = "%s-%s" % (package_name, version) os.chdir(full_project_dir) patch_command = "git diff --relative %s..%s" % \ (last_tag, "HEAD") output = run_command(patch_command) # If the diff contains 1 line then there is no diff: linecount = len(output.split("\n")) if linecount == 1: return name_and_version = "%s %s" % (package_name, relative_project_dir) # Otherwise, print out info on the diff for this package: print("#" * len(name_and_version)) print(name_and_version) print("#" * len(name_and_version)) print("") print patch_command print("") print(output) print("") print("") print("") print("") print("")
def _print_log(self, global_config, package_name, version, project_dir): """ Print the log between the most recent package tag and HEAD, if necessary. """ last_tag = "%s-%s" % (package_name, version) try: os.chdir(project_dir) patch_command = "git log --pretty=oneline --relative %s..%s -- %s" % \ (last_tag, "HEAD", ".") output = run_command(patch_command) if (output): print("-" * (len(last_tag) + 8)) print("%s..%s:" % (last_tag, "HEAD")) print(output) except: print("%s no longer exists" % project_dir)
def _read_project_config(self, project_name, build_dir, tag, no_cleanup): """ Read and return project build properties if they exist. This is done by checking for a build.py.props in the projects directory at the time the tag was made. To accomodate older tags prior to build.py, we also check for the presence of a Makefile with NO_TAR_GZ, and include a hack to assume build properties in this scenario. If no project specific config can be found, use the global config. """ debug("Determined package name to be: %s" % project_name) properties_file = None wrote_temp_file = False # Use the properties file in the current project directory, if it # exists: current_props_file = os.path.join(os.getcwd(), BUILD_PROPS_FILENAME) if (os.path.exists(current_props_file)): properties_file = current_props_file # Check for a build.py.props back when this tag was created and use it # instead. (if it exists) if tag: relative_dir = get_relative_project_dir(project_name, tag) cmd = "git show %s:%s%s" % (tag, relative_dir, BUILD_PROPS_FILENAME) debug(cmd) (status, output) = commands.getstatusoutput(cmd) temp_filename = "%s-%s" % (random.randint(1, 10000), BUILD_PROPS_FILENAME) temp_props_file = os.path.join(build_dir, temp_filename) if status == 0: properties_file = temp_props_file f = open(properties_file, 'w') f.write(output) f.close() wrote_temp_file = True else: # HACK: No build.py.props found, but to accomodate packages # tagged before they existed, check for a Makefile with # NO_TAR_GZ defined and make some assumptions based on that. cmd = "git show %s:%s%s | grep NO_TAR_GZ" % \ (tag, relative_dir, "Makefile") debug(cmd) (status, output) = commands.getstatusoutput(cmd) if status == 0 and output != "": properties_file = temp_props_file debug("Found Makefile with NO_TAR_GZ") f = open(properties_file, 'w') f.write(ASSUMED_NO_TAR_GZ_PROPS) f.close() wrote_temp_file = True config = ConfigParser.ConfigParser() if properties_file != None: debug("Using build properties: %s" % properties_file) config.read(properties_file) else: debug("Unable to locate custom build properties for this package.") debug(" Using global.build.py.props") # TODO: Not thrilled with this: if wrote_temp_file and not no_cleanup: # Delete the temp properties file we created. run_command("rm %s" % properties_file) return config