<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def r_update(self):
 """ Updates a fork Master - Check the ref of the origin repository - Patch reference of fork repository - Return status to Perseids :return: JSON Response with status_code 201 if successful. """


        # Getting Master Branch
        upstream = self.get_ref(self.master_upstream, origin=self.upstream)
        if isinstance(upstream, bool):
            return (ProxyError(
                404, "Upstream Master branch '{0}' does not exist".format(self.master_upstream),
                step="get_upstream_ref"
            )).response()
        elif isinstance(upstream, self.ProxyError):
            return upstream.response()

        # Patching
        new_sha = self.patch_ref(upstream)
        if isinstance(new_sha, self.ProxyError):
            return new_sha.response()

        self.logger.info("Updated repository {} to sha {}".format(self.origin, new_sha), extra={"former_sha": upstream})
        return jsonify({
            "status": "success",
            "commit": new_sha
        })