def checkout_new_translations_branch(new_version_number): util.chdir_repo(translations_repo) subprocess.call('git checkout master', shell=True) subprocess.call('git pull origin master', shell=True) new_branch_name = '{}_release_additions'.format(new_version_number) subprocess.call('git checkout -b {}'.format(new_branch_name), shell=True) return new_branch_name
def checkout_new_translations_branch(new_version_number): util.chdir_repo(translations_repo) subprocess.call("git checkout master", shell=True) subprocess.call("git pull origin master", shell=True) new_branch_name = "{}_release_additions".format(new_version_number) subprocess.call("git checkout -b {}".format(new_branch_name), shell=True) return new_branch_name
def get_updated_translations(repo, relative_path, filename): """ Return a string containing the updated text that should go into the master hq translations file from the given file """ util.chdir_repo(repo) os.chdir(relative_path) with open(filename, 'r', encoding='utf-8') as f: return f.read().strip()
def get_updated_translations(repo, relative_path, filename): """ Return a string containing the updated text that should go into the master hq translations file from the given file """ util.chdir_repo(repo) os.chdir(relative_path) with open(filename, "r", encoding="utf-8") as f: return f.read().strip()
def create_tags_for_repos(branch_name, tag_name): """ Creates the release tag from provided branch. """ print("creating release tags '{}' from '{}' branches".format( tag_name, branch_name)) for repo in REPOS: util.chdir_repo(repo) create_tag_from_branch(branch_name, tag_name) util.chdir_base()
def mark_version_as_alpha(branch_name): util.chdir_repo('commcare-core') subprocess.call('git checkout {}'.format(branch_name), shell=True) subprocess.call('git pull origin {}'.format(branch_name), shell=True) replace_func(set_dev_tag_to_alpha, 'application/build.properties') commit_message = 'Automated commit adding dev tag to commcare version' review_and_commit_changes(branch_name, commit_message) subprocess.call('git checkout master', shell=True) util.chdir_base()
def create_tags_for_repos(branch_name, tag_name): """ Creates the release tag from provided branch. """ print("creating release tags '{}' from '{}' branches".format(tag_name, branch_name)) for repo in REPOS: util.chdir_repo(repo) create_tag_from_branch(branch_name, tag_name) util.chdir_base()
def create_hotfix_tags(hotfix_repos, version): """ Create hotfix tags from hotfix branch for given repos. """ branch_name = "{}{}".format(BRANCH_BASE, version.short_string()) tag_name = "{}{}".format(BRANCH_BASE, version) for repo in hotfix_repos: util.chdir_repo(repo) create_tag_from_branch(branch_name, tag_name) util.chdir_base()
def update_android_hotfix_version(branch): """ Update hotfix version in AndroidManifest and push hotfix branch. """ util.chdir_repo('commcare-android') subprocess.call('git checkout {}'.format(branch), shell=True) replace_func(update_manifest_hotfix_version, 'app/AndroidManifest.xml') review_and_commit_changes(branch, 'Automated hotfix version bump') util.chdir_base()
def update_commcare_hotfix_version_numbers(branch): """ Update hotfix version in build.properties on hotfix branch """ util.chdir_repo('commcare-core') subprocess.call('git checkout {}'.format(branch), shell=True) replace_func(incr_build_prop_hotfix_version, 'application/build.properties') review_and_commit_changes(branch, 'Automated hotfix version bump') util.chdir_base()
def mark_version_as_release(branch_name): util.chdir_repo('commcare-j2me') print("marking commcare-core {} branch for release".format(branch_name)) subprocess.call('git checkout {}'.format(branch_name), shell=True) subprocess.call('git pull origin {}'.format(branch_name), shell=True) replace_func(set_dev_tag_to_release, 'application/build.properties') commit_message = "Automated: removing 'alpha' from version" review_and_commit_changes(branch_name, commit_message) util.chdir_base()
def update_android_version_numbers(): """ Update version numbers in AndroidManifest and push master. """ util.chdir_repo('commcare-android') subprocess.call('git checkout master', shell=True) replace_func(update_manifest_version, 'app/AndroidManifest.xml') update_resource_string_version() review_and_commit_changes('master', 'Automated version bump') util.chdir_base()
def add_hotfix_version_to_android(branch_name, hotfix_count): util.chdir_repo('commcare-android') print("add hotfix ver. to commcare-android branch {}".format(branch_name)) subprocess.call('git checkout {}'.format(branch_name), shell=True) subprocess.call('git pull origin {}'.format(branch_name), shell=True) replace_func(set_hotfix_version_to_zero, 'app/AndroidManifest.xml') commit_message = 'Automated: adding hotfix version to AndroidManifest' review_and_commit_changes(branch_name, commit_message) util.chdir_base()
def close_branches(branch_name): if not util.branch_exists_in_repos(branch_name, REPOS): raise Exception("{} branch doesn't exists".format(branch_name)) print("removing local instances of the {} branch".format(branch_name)) print("You will also want to close the remote github branches") print("\tthis'll be automated once the script's been working for a while.") for repo in REPOS: util.chdir_repo(repo) print("removing {} branch of {} repo".format(branch_name, repo)) subprocess.call('git checkout master', shell=True) subprocess.call('git branch -d {}'.format(branch_name), shell=True) util.chdir_base()
def update_commcare_version_numbers(): """ Update version numbers in build.properties and CommCareConfigEngin on master. """ util.chdir_repo('commcare-core') subprocess.call('git checkout master', shell=True) replace_func( replace_config_engine_version, 'src/cli/java/org/commcare/util/engine/CommCareConfigEngine.java') review_and_commit_changes('master', 'Automated version bump') util.chdir_base()
def update_commcare_version_numbers(): """ Update version numbers in build.properties and CommCareConfigEngin on master. """ util.chdir_repo('commcare-core') subprocess.call('git checkout master', shell=True) replace_func(replace_config_engine_version, 'util/src/org/commcare/util/engine/CommCareConfigEngine.java') review_and_commit_changes('master', 'Automated version bump') util.chdir_base()
def get_updated_strings_block(): """ Return a string containing the updated text that should go into the master hq translations file from the strings.xml file in the mobile codebase. Because it is an xml file instead of a plain text file, the extraction needs to be done in a different way from all of the other files """ util.chdir_repo(commcare_android_repo) subprocess.call("git checkout master", shell=True) os.chdir(ccodk_strings_subfolder) tree = ET.parse(ccodk_strings_filename) resources = tree.getroot() string_list = [] for string in resources.findall("string"): translatable_value = string.get("{}translatable".format(namespace)) if translatable_value == "true": name = string.get("name") value = string.text if name is not None and value is not None: name_with_prefix = "odk_{}".format(name) value = unescape_quotes(replace_string_format_syntax(value)) string_list.append(name_with_prefix + "=" + value + "\n") return "".join(string_list)
def get_updated_strings_block(): """ Return a string containing the updated text that should go into the master hq translations file from the strings.xml file in the mobile codebase. Because it is an xml file instead of a plain text file, the extraction needs to be done in a different way from all of the other files """ util.chdir_repo(commcare_android_repo) subprocess.call('git checkout master', shell=True) os.chdir(ccodk_strings_subfolder) tree = ET.parse(ccodk_strings_filename) resources = tree.getroot() string_list = [] for string in resources.findall('string'): translatable_value = string.get('{}translatable'.format(namespace)) if translatable_value == 'true': name = string.get('name') value = string.text if name is not None and value is not None: name_with_prefix = 'odk_{}'.format(name) value = unescape_quotes(replace_string_format_syntax(value)) string_list.append(name_with_prefix + '=' + value + '\n') return "".join(string_list)
def create_branch(repo, branch_name): util.chdir_repo(repo) subprocess.call('git checkout -b {}'.format(branch_name), shell=True) subprocess.call('git push origin {}'.format(branch_name), shell=True) util.chdir_base()
def checkout_master(repo): util.chdir_repo(repo) subprocess.call('git checkout master', shell=True) util.chdir_base()