Created
May 29, 2023 11:46
-
-
Save moodymudskipper/04ae38a649ba19f9dfd45cf482e5a957 to your computer and use it in GitHub Desktop.
git dm draft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objects_output <- system("git cat-file --batch-check --batch-all-objects", intern = TRUE) | |
objects_list <- strsplit(objects_output, "\\s") | |
objects <- data.frame(ObjectID = sapply(objects_list, "[[", 1), | |
Type = sapply(objects_list, "[[", 2), | |
Size = as.numeric(sapply(objects_list, "[[", 3))) | |
# commits | |
commits_output <- system('git log --pretty=format:"%H|/|%an|/|%ae|/|%cn|/|%ce|/|%s|/|%P|/|%T|/|%ct" --all', intern = TRUE) | |
commits_list <- strsplit(commits_output, "\\|/\\|") | |
commits <- data.frame(CommitID = sapply(commits_list, "[[", 1), | |
Author = sapply(commits_list, "[[", 2), | |
AuthorEmail = sapply(commits_list, "[[", 3), | |
Committer = sapply(commits_list, "[[", 4), | |
CommitterEmail = sapply(commits_list, "[[", 5), | |
CommitMessage = sapply(commits_list, "[[", 6), | |
ParentCommit = sapply(commits_list, "[[", 7), | |
TreeID = sapply(commits_list, "[[", 8), | |
Timestamp = as.POSIXct(as.numeric(sapply(commits_list, "[[", 9)), origin = "1970-01-01")) | |
# trees table | |
trees_output <- system("git ls-tree --full-tree -r HEAD", intern = TRUE) | |
trees_list <- strsplit(trees_output, "\\t| ") | |
trees <- data.frame( | |
tree_id = sapply(trees_list, "[[", 1), | |
type = sapply(trees_list, "[[", 2), | |
object_id = sapply(trees_list, "[[", 3), | |
path = sapply(trees_list, "[[", 4) | |
) | |
# tags | |
# tags_output <- system("git show-ref --tags --abbrev=40 --hash --dereference", intern = TRUE) | |
# tags_list <- strsplit(tags_output, "\\s") | |
# tags <- data.frame(TagID = sapply(tags_list, "[[", 1), | |
# ObjectID = sapply(tags_list, "[[", 2), | |
# TagName = sapply(tags_list, "[[", 3), | |
# Tagger = NA, | |
# TaggerEmail = NA, | |
# TagMessage = NA, | |
# Timestamp = NA) | |
# branches | |
branches_output <- system("git show-ref --heads --abbrev=40 --hash", intern = TRUE) | |
branches_list <- strsplit(branches_output, "\\s") | |
branches <- data.frame(BranchName = sapply(branches_list, "[[", 2), | |
CommitID = sapply(branches_list, "[[", 1)) | |
# authors | |
blobs_output <- system("git cat-file --batch-check --batch-all-objects | grep blob", intern = TRUE) | |
blobs_list <- strsplit(blobs_output, "\\s") | |
blobs <- data.frame(BlobID = sapply(blobs_list, "[[", 1), | |
Size = as.numeric(sapply(blobs_list, "[[", 3)), | |
Content = NA) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment