github.com/purpleclay/gitz@v0.8.2-0.20240515052600-43f80eea2fe1/docs/git/show.md (about) 1 --- 2 icon: material/text-search 3 title: Inspect an object within a repository 4 description: Retrieve details about a specific object from within a repository 5 --- 6 7 # Inspect an object within a repository 8 9 [:simple-git:{ .git-icon } Git Documentation](https://git-scm.com/docs/git-show) 10 11 Retrieve detailed information about an object within a repository by its unique reference. 12 13 ## Inspect a tag 14 15 Detailed information about a tag, and its associated commit, can be retrieved from a repository by passing its reference to `ShowTags`. The GPG signature of the commit is also retrieved if present. 16 17 ```{ .go .select linenums="1" } 18 package main 19 20 import ( 21 "fmt" 22 "time" 23 24 git "github.com/purpleclay/gitz" 25 ) 26 27 func main() { 28 client, _ := git.NewClient() 29 30 // Querying a tag from the gpg-import project 31 32 tags, _ := client.ShowTags("0.3.2") 33 34 tag := tags[0] 35 if tag.Annotation != nil { 36 fmt.Printf("Tagger: %s <%s>\n", 37 tag.Annotation.Tagger.Name, tag.Annotation.Tagger.Email) 38 fmt.Printf("TaggerDate: %s\n", 39 tag.Annotation.TaggerDate.Format(time.RubyDate)) 40 fmt.Printf("Message: %s\n\n", tag.Annotation.Message) 41 } 42 43 fmt.Printf("Author: %s <%s>\n", 44 tag.Commit.Author.Name, tag.Commit.Author.Email) 45 fmt.Printf("AuthorDate: %s\n", 46 tag.Commit.AuthorDate.Format(time.RubyDate)) 47 fmt.Printf("Commit: %s <%s>\n", 48 tag.Commit.Committer.Name, tag.Commit.Committer.Email) 49 fmt.Printf("CommitDate: %s\n", 50 tag.Commit.CommitterDate.Format(time.RubyDate)) 51 fmt.Printf("Message: %s\n\n", tag.Commit.Message) 52 if tag.Commit.Signature != nil { 53 fmt.Printf("Fingerprint: %s\n", tag.Commit.Signature.Fingerprint) 54 } 55 } 56 ``` 57 58 ```{ .text .no-select .no-copy } 59 Tagger: purpleclay <purpleclaygh@gmail.com> 60 TaggerDate: Thu Jun 29 07:05:18 +0100 2023 61 Message: chore: tagged for release 0.3.2 62 63 Author: Purple Clay <purpleclaygh@gmail.com> 64 AuthorDate: Thu Jun 29 06:40:51 +0100 2023 65 Commit: GitHub <noreply@github.com> 66 CommitDate: Thu Jun 29 06:40:51 +0100 2023 67 Message: fix: imported gpg key fails to sign when no tty is present (#33) 68 Fingerprint: 4AEE18********** 69 ``` 70 71 ## Inspect a commit 72 73 Retrieve information about a specific commit by passing its reference to `ShowCommits`. Including its GPG signature, if present. 74 75 ## Inspect a tree 76 77 Call `ShowTrees` to retrieve a listing of all files and directories within a specific tree index of a repository. 78 79 ```{ .go .select linenums="1" } 80 package main 81 82 import ( 83 "fmt" 84 85 git "github.com/purpleclay/gitz" 86 ) 87 88 func main() { 89 client, _ := git.NewClient() 90 91 // Query the gittest directory tree within gitz 92 93 tree, _ := client.ShowTrees("ad4a68f6628ba9a6c367fe213eb8136fdb95ebcd") 94 for _, entry := range tree[0].Entries { 95 fmt.Printf("%s\n", entry) 96 } 97 } 98 ``` 99 100 ```{ .text .no-select .no-copy } 101 log.go 102 log_test.go 103 repository.go 104 repository_test.go 105 ``` 106 107 ## Inspect a blob 108 109 Retrieve the contents of a file (blob) from a repository by passing its reference to `ShowBlobs`.