mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	provision: Rename file_hash_updated to file_or_package_hash_updated.
Check for changes in package version as well along with the files.
This commit is contained in:
		@@ -313,13 +313,20 @@ def parse_lsb_release():
 | 
				
			|||||||
        distro_info[k] = v
 | 
					        distro_info[k] = v
 | 
				
			||||||
    return distro_info
 | 
					    return distro_info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def file_hash_updated(paths, hash_name, is_force):
 | 
					def file_or_package_hash_updated(paths, hash_name, is_force, package_versions=[]):
 | 
				
			||||||
    # type: (List[str], str, bool) -> bool
 | 
					    # type: (List[str], str, bool, List[str]) -> bool
 | 
				
			||||||
 | 
					    # Check whether the files or package_versions passed as arguments
 | 
				
			||||||
 | 
					    # changed compared to the last execution.
 | 
				
			||||||
    sha1sum = hashlib.sha1()
 | 
					    sha1sum = hashlib.sha1()
 | 
				
			||||||
    for path in paths:
 | 
					    for path in paths:
 | 
				
			||||||
        with open(path, 'rb') as file_to_hash:
 | 
					        with open(path, 'rb') as file_to_hash:
 | 
				
			||||||
            sha1sum.update(file_to_hash.read())
 | 
					            sha1sum.update(file_to_hash.read())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    # The ouput of tools like build_pygments_data depends
 | 
				
			||||||
 | 
					    # on the version of some pip packages as well.
 | 
				
			||||||
 | 
					    for package_version in package_versions:
 | 
				
			||||||
 | 
					        sha1sum.update(package_version.encode("utf-8"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    hash_path = os.path.join(get_dev_uuid_var_path(), hash_name)
 | 
					    hash_path = os.path.join(get_dev_uuid_var_path(), hash_name)
 | 
				
			||||||
    new_hash = sha1sum.hexdigest()
 | 
					    new_hash = sha1sum.hexdigest()
 | 
				
			||||||
    run(['touch', hash_path])
 | 
					    run(['touch', hash_path])
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,7 +14,7 @@ ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__f
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
sys.path.append(ZULIP_PATH)
 | 
					sys.path.append(ZULIP_PATH)
 | 
				
			||||||
from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING, \
 | 
					from scripts.lib.zulip_tools import run, subprocess_text_output, OKBLUE, ENDC, WARNING, \
 | 
				
			||||||
    get_dev_uuid_var_path, FAIL, parse_lsb_release, file_hash_updated
 | 
					    get_dev_uuid_var_path, FAIL, parse_lsb_release, file_or_package_hash_updated
 | 
				
			||||||
from scripts.lib.setup_venv import (
 | 
					from scripts.lib.setup_venv import (
 | 
				
			||||||
    setup_virtualenv, VENV_DEPENDENCIES, THUMBOR_VENV_DEPENDENCIES
 | 
					    setup_virtualenv, VENV_DEPENDENCIES, THUMBOR_VENV_DEPENDENCIES
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
@@ -296,7 +296,7 @@ def main(options):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    webfont_paths = ["tools/generate-custom-icon-webfont", "static/icons/fonts/template.hbs"]
 | 
					    webfont_paths = ["tools/generate-custom-icon-webfont", "static/icons/fonts/template.hbs"]
 | 
				
			||||||
    webfont_paths += glob.glob('static/assets/icons/*')
 | 
					    webfont_paths += glob.glob('static/assets/icons/*')
 | 
				
			||||||
    if file_hash_updated(webfont_paths, "webfont_files_hash", options.is_force):
 | 
					    if file_or_package_hash_updated(webfont_paths, "webfont_files_hash", options.is_force):
 | 
				
			||||||
        run(["tools/generate-custom-icon-webfont"])
 | 
					        run(["tools/generate-custom-icon-webfont"])
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print("No need to run `tools/generate-custom-icon-webfont`.")
 | 
					        print("No need to run `tools/generate-custom-icon-webfont`.")
 | 
				
			||||||
@@ -307,7 +307,7 @@ def main(options):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    email_source_paths = ["tools/inline-email-css", "templates/zerver/emails/email.css"]
 | 
					    email_source_paths = ["tools/inline-email-css", "templates/zerver/emails/email.css"]
 | 
				
			||||||
    email_source_paths += glob.glob('templates/zerver/emails/*.source.html')
 | 
					    email_source_paths += glob.glob('templates/zerver/emails/*.source.html')
 | 
				
			||||||
    if file_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
 | 
					    if file_or_package_hash_updated(email_source_paths, "last_email_source_files_hash", options.is_force):
 | 
				
			||||||
        run(["tools/inline-email-css"])
 | 
					        run(["tools/inline-email-css"])
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        print("No need to run `tools/inline-email-css`.")
 | 
					        print("No need to run `tools/inline-email-css`.")
 | 
				
			||||||
@@ -377,7 +377,7 @@ def main(options):
 | 
				
			|||||||
        paths += glob.glob('static/locale/*/LC_MESSAGES/*.po')
 | 
					        paths += glob.glob('static/locale/*/LC_MESSAGES/*.po')
 | 
				
			||||||
        paths += glob.glob('static/locale/*/translations.json')
 | 
					        paths += glob.glob('static/locale/*/translations.json')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if file_hash_updated(paths, "last_compilemessages_hash", options.is_force):
 | 
					        if file_or_package_hash_updated(paths, "last_compilemessages_hash", options.is_force):
 | 
				
			||||||
            run(["./manage.py", "compilemessages"])
 | 
					            run(["./manage.py", "compilemessages"])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print("No need to run `manage.py compilemessages`.")
 | 
					            print("No need to run `manage.py compilemessages`.")
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user