I set up my own server to host some private git repositories.
I am working on a visual representation (using a php backend) of my private 'repo base'.
It all works fine and I may open-source it at some point.
My current issue: Creating a list of all repositories (I did that already), which is sorted by the last commit times (to the master-branches).
I currently use this function to get a list of my (bare) git repositories:
function listRepositories() {
global $SYSTEM_PATH;
exec("ls $SYSTEM_PATH/repos/ -t", $repoDirectories);
$repos = array_map(function($repo) {
return str_replace("$SYSTEM_PATH/repos/", "", $repo);
}, $repoDirectories);
return $repos;
}
However, the ls $SYSTEM_PATH/repos/ -t
command I currently use to get a list of repos does not sort them the way I want.
If I copy older repos into the repository directory ($SYSTEM_PATH/repos/
), they appear on top of the list.
This command returns the last commit time (unix timestamp):
git log -1 --format=%ct
However, I did not yet manage to combine all that to achieve what I want in a efficient way.
Thank you for helping me achieve it, I am grateful for everything this community taught me!
Related Questions:
- Last git commit time: How do I get last commit date from git repository?
- The same for branches: How can I get a list of Git branches, ordered by most recent commit?