commit - 881548f6eccc1a150ea05bb582eb87d6bac33c77
commit + 58c7efd8c59ca23b952579983f881c24aafcf666
blob - 1b978b080ce06ac36cc901adb1b213b8e0698998
blob + e561b39993ca0e4f7331670e77114d960d47dbb8
--- last_commit_cgi/got_last_commit_file.py
+++ last_commit_cgi/got_last_commit_file.py
# Parse parameters
repo, file_path = get_query_params()
log(1,'repo, file_path:%s %s' % (repo, file_path))
-
+
# Validate inputs
if not repo or not file_path:
log(0, '%s - reply 400 - ERROR:missing path and/or file parameters' % (time.ctime()))
"Error: Missing required parameters 'path' and/or 'file'"
)
return
-
+
# Build repository path
repo_path = os.path.join(REPO_BASE, repo)
log(1, 'repo_path:%s %s' % (repo_path, os.path.isdir(repo_path)))
-
+
# Check if repository exists
if not os.path.isdir(repo_path):
log(0, '%s - reply 404 - ERROR:no repository found at %s' % (time.ctime(), repo_path))
f"Error: Repository '{repo}' not found"
)
return
-
+
# Get latest commit
commit = get_latest_commit(repo_path)
log(1, 'commit:%s' % (commit))
-
+
if not commit:
log(0, '%s - reply 500 - ERROR:no "commit" found in got log for %s' % (time.ctime(), repo_path))
send_response(
f"Error: Could not retrieve latest commit for repository '{repo}'"
)
return
-
+
# Build gotwebd URL
folder, filename = os.path.split(file_path)
if folder in ("/"):
"file": filename,
"path": repo
}
-
log(1, 'params:%s' % (params))
gotwebd_url = "/?" + urlencode(params)
log(0, '%s - reply 302 - %s' % (time.ctime(), gotwebd_url))
#/?action=blobraw&commit={commit}&folder=&file={file_path}&path={repo}"
-
+
# Send redirect
send_response(
"302 Found",