<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_version(path, ref=None):
 """Update version file using git desribe"""

    with lcd(dirname(path)):
        version = make_version(ref)
    if (env.get('full') or not os.path.exists(path)
            or version != open(path).read().strip()):
        with open(path, 'w') as out:
            out.write(version + '\n')
    return version