You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm sharing my implementation for showing last commit and commits of directories and files via api.
I do this by myself because the APIs of current version of Gitea not provide these. (expecting new version will).
I use redis to build indices:
Build last commit sha index for all files of each commit.
Build commit history index for each file changed in each commit.
Build commit summary index for each commit.
last commit sha index
key:
`{files:${owner}:${repo}}:${ref}`// ref is sha of commit or refs/tags/... or refs/heads/...
value: Hash<filename, sha>, every path visible, including the root path, are tracked.
When a commit is pushed to a branch:
if the branch does not exist before(the key doesn't exist), copy the files of the before commit to this branch. using redis COPY command.
update all paths affected by files changed on the branch. using redis HMSET command.
copy the files of the branch to the after commit. usinig redis COPY command.
To ls a path, you could combine the response of GET /repos/{owner}/{repo}/contents/{filepath} API and the result of HMGET command.
commit history index:
key:
`{commits:${owner}:${repo}}:${sha}:${filename}`
value: List<sha>, all commits' sha are tracked in newer to older order.
When a commit is pushed to a branch:
if the branch does not exist before(the key doesn't exist), push the sha of the before commit to all paths affected by files changed on this branch. using redis LPUSH command.
push the sha of the after commit to all paths affected by files changed on this branch. using redis LPUSH command.
copy all paths updated on this branch to the after commit. using redis COPY command.
Adds an API endpoint `api/v1/repos/{owner}/{repo}/git/history/{filepath}` to get the commits affecting the given file or directory.
Closes#16206 and closes#16703
Chianina
pushed a commit
to Chianina/gitea
that referenced
this issue
Mar 28, 2022
Adds an API endpoint `api/v1/repos/{owner}/{repo}/git/history/{filepath}` to get the commits affecting the given file or directory.
Closesgo-gitea#16206 and closesgo-gitea#16703
[x]
):Description
...
Hello there,
I'm sharing my implementation for showing last commit and commits of directories and files via api.
I do this by myself because the APIs of current version of Gitea not provide these. (expecting new version will).
I use redis to build indices:
last commit sha index
key:
value:
Hash<filename, sha>
, every path visible, including the root path, are tracked.When a commit is pushed to a branch:
before
commit to this branch. using redisCOPY
command.HMSET
command.after
commit. usinig redisCOPY
command.To
ls
a path, you could combine the response ofGET /repos/{owner}/{repo}/contents/{filepath}
API and the result ofHMGET
command.commit history index:
key:
`{commits:${owner}:${repo}}:${sha}:${filename}`
value:
List<sha>
, all commits' sha are tracked in newer to older order.When a commit is pushed to a branch:
before
commit to all paths affected by files changed on this branch. using redisLPUSH
command.after
commit to all paths affected by files changed on this branch. using redisLPUSH
command.after
commit. using redisCOPY
command.HMSET {commit:$owner:$repo}:$sha message '$message' timestamp '$timestamp' author '$author'
To query history of a path, you could use
LRANGE
to get the SHA list and then useMGET
to get commit summaries.Screenshots
The text was updated successfully, but these errors were encountered: