|
97 | 97 | * [Create a release asset](#create-a-release-asset)
|
98 | 98 | * [Update a release asset](#update-a-release-asset)
|
99 | 99 | * [Remove a release asset](#remove-a-release-asset)
|
| 100 | + * [Gists](#gists) |
| 101 | + * [Getting gists](#getting-gists) |
| 102 | + * [Download a gist](#download-a-gist) |
| 103 | + * [Fork a gist](#fork-a-gist) |
| 104 | + * [Creating a gist](#creating-a-gist) |
| 105 | + * [Removing a gist](#removing-a-gist) |
| 106 | + * [Updating a gist](#updating-a-gist) |
| 107 | + * [Starring a gist](#starring-a-gist) |
| 108 | + * [Getting gist comments](#getting-gist-comments) |
| 109 | + * [Adding a gist comment](#adding-a-gist-comment) |
| 110 | + * [Changing a gist comment](#changing-a-gist-comment) |
| 111 | + * [Removing a gist comment](#removing-a-gist-comment) |
100 | 112 | * [Advanced](#advanced)
|
101 | 113 | * [Migrating blog comments to GitHub issues](#migrating-blog-comments-to-github-issues)
|
102 | 114 |
|
@@ -869,6 +881,169 @@ or with pipelining...
|
869 | 881 |
|
870 | 882 | ```powershell
|
871 | 883 | $asset | Remove-GitHubReleaseAsset -force
|
| 884 | +
|
| 885 | +---------- |
| 886 | +
|
| 887 | +### Gists |
| 888 | +
|
| 889 | +#### Getting gists |
| 890 | +```powershell |
| 891 | +# There are many options here: |
| 892 | +
|
| 893 | +# 1. Getting all gists for the current authenticated user: |
| 894 | +Get-GitHubGist |
| 895 | +
|
| 896 | +# 1b. Getting all gists for the current authenticated user that were updated in the past 6 days. |
| 897 | +Get-GitHubGist -Since ((Get-Date).AddDays(-6)) |
| 898 | +
|
| 899 | +# 2. Get all starred gists for the current authenticated user |
| 900 | +Get-GitHubGist -Starred |
| 901 | +
|
| 902 | +# 3. Get all public gists for a specific user |
| 903 | +Get-GitHubGist -UserName 'octocat' |
| 904 | +
|
| 905 | +# 4. Get all public gists (well, the first 3000): |
| 906 | +Get-GitHubGist -Public |
| 907 | +
|
| 908 | +# 5. Get a specific gist |
| 909 | +Get-GitHubGist -Gist '6cad326836d38bd3a7ae' |
| 910 | +
|
| 911 | +# 5a. List all commits for a specific gist |
| 912 | +Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Commits |
| 913 | +
|
| 914 | +# 5b. Get a gist at a specific commit (Sha) |
| 915 | +Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Sha 'de5b9b59d1f28206e8d646c7c8025e9809d0ed73' |
| 916 | +
|
| 917 | +# 5c. Get all of the forks for a gist |
| 918 | +Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Forks |
| 919 | +``` |
| 920 | + |
| 921 | +#### Download a gist |
| 922 | +```powershell |
| 923 | +Get-GitHubGist -Gist '6cad326836d38bd3a7ae' -Path 'c:\users\octocat\downloads\gist\' |
| 924 | +``` |
| 925 | + |
| 926 | +#### Fork a gist |
| 927 | +```powershell |
| 928 | +Fork-GitHubGist -Gist '6cad326836d38bd3a7ae' |
| 929 | +``` |
| 930 | + |
| 931 | +#### Creating a gist |
| 932 | +```powershell |
| 933 | +# You can create a gist by specifying a single file's content in-line... |
| 934 | +New-GitHubGist -FileName 'foo.txt' -Content 'foo content' |
| 935 | +
|
| 936 | +# or by providing one or more files that should be part of the gist |
| 937 | +New-GitHubGist -File @('c:\files\foo.txt', 'c:\files\bar.txt') |
| 938 | +@('c:\files\foo.txt', 'c:\files\bar.txt') | New-GitHubGist |
| 939 | +``` |
| 940 | + |
| 941 | +#### Removing a gist |
| 942 | +```powershell |
| 943 | +Remove-GitHubGist -Gist '6cad326836d38bd3a7ae' |
| 944 | +``` |
| 945 | + |
| 946 | +#### Updating a gist |
| 947 | +```powershell |
| 948 | +$gist = New-GitHubGist -FileName 'foo.txt' -Content 'content' |
| 949 | +
|
| 950 | +# The main method to use is Set-GitHubGist, however it is quite complicated. |
| 951 | +$params = @{ |
| 952 | + Description = 'new description' # modifies the description of the gist |
| 953 | + Update = @{ |
| 954 | + 'foo.txt' = @{ |
| 955 | + fileName = 'alpha.txt' # Will rename foo.txt -> alpha.txt |
| 956 | + content = 'updated content' # and will also update its content |
| 957 | + } |
| 958 | + 'bar.txt' = @{ |
| 959 | + filePath = 'c:\files\bar.txt' # Will upload the content of bar.txt to the gist. |
| 960 | + } |
| 961 | + } |
| 962 | + Delete = @('bar.txt') |
| 963 | + Force = $true # avoid confirmation prompting due to the deletion |
| 964 | +} |
| 965 | +
|
| 966 | +Set-GitHubGist -Gist $gist.id @params |
| 967 | +
|
| 968 | +# Therefore, you can use simpler helper methods to accomplish atomic tasks |
| 969 | +Set-GistHubGistFile -Gist $gist.id -FileName 'foo.txt' -Content 'updated content' |
| 970 | +
|
| 971 | +# This will update the text in the existing file 'foo.txt' and add the file 'bar.txt' |
| 972 | +$gist | Set-GitHubGistFile -File ('c:\files\foo.txt', 'c:\files\bar.txt') |
| 973 | +
|
| 974 | +Rename-GistHubGistFile -Gist $gist.id -FileName 'foo.txt' -NewName 'bar.txt' |
| 975 | +
|
| 976 | +$gist | Remove-GitHubGistFile -FileName 'bar.txt' -Force |
| 977 | +
|
| 978 | +``` |
| 979 | + |
| 980 | +#### Starring a gist |
| 981 | +```powershell |
| 982 | +$gistId = '6cad326836d38bd3a7ae' |
| 983 | +
|
| 984 | +# All of these options will star the same gist |
| 985 | +Star-GitHubGist -Gist $gistId |
| 986 | +Add-GitHubGistStar -Gist $gistId |
| 987 | +Set-GitHubGistStar -Gist $gistId -Star |
| 988 | +Get-GitHubGist -Gist $gistId | Star-GitHubGist |
| 989 | +
|
| 990 | +# All of these options will unstar the same gist |
| 991 | +Unstar-GitHubGist -Gist $gistId |
| 992 | +Remove-GitHubGistStar -Gist $gistId |
| 993 | +Set-GitHubGistStar -Gist $gistId |
| 994 | +Set-GitHubGistStar -Gist $gistId -Star:$false |
| 995 | +Get-GitHubGist -Gist $gistId | Unstar-GitHubGist |
| 996 | +
|
| 997 | +# All of these options will tell you if you have starred a gist |
| 998 | +Test-GitHubGistStar -Gist $gistId |
| 999 | +Get-GitHubGist -Gist $gistId | Test-GitHubGistStar |
| 1000 | +``` |
| 1001 | + |
| 1002 | +#### Getting gist comments |
| 1003 | +```powershell |
| 1004 | +$gistId = '6cad326836d38bd3a7ae' |
| 1005 | +$commentId = 1507813 |
| 1006 | +
|
| 1007 | +# You can get all comments for a gist with any of these options: |
| 1008 | +Get-GitHubGistComment -Gist $gistId |
| 1009 | +Get-GitHubGist -Gist $gistId | Get-GitHubGistComment |
| 1010 | +
|
| 1011 | +# You can retrieve an individual comment like this: |
| 1012 | +Get-GitHubGistComment -Gist $gistId -Comment $commentId |
| 1013 | +``` |
| 1014 | + |
| 1015 | +#### Adding a gist comment |
| 1016 | +```powershell |
| 1017 | +$gistId = '6cad326836d38bd3a7ae' |
| 1018 | +
|
| 1019 | +New-GitHubGistComment -Gist $gistId -Body 'Hello World' |
| 1020 | +
|
| 1021 | +# or with the pipeline |
| 1022 | +Get-GitHubGist -Gist $gistId | New-GitHubGistComment -Body 'Hello World' |
| 1023 | +``` |
| 1024 | + |
| 1025 | +#### Changing a gist comment |
| 1026 | +```powershell |
| 1027 | +$gistId = '6cad326836d38bd3a7ae' |
| 1028 | +$commentId = 1507813 |
| 1029 | +
|
| 1030 | +Set-GitHubGistComment -Gist $gistId -Comment $commentId -Body 'Updated comment' |
| 1031 | +
|
| 1032 | +# or with the pipeline |
| 1033 | +Get-GitHubGist -Gist $gistId -Comment $commentId | Set-GitHubGistComment -Body 'Updated comment' |
| 1034 | +``` |
| 1035 | + |
| 1036 | +#### Removing a gist comment |
| 1037 | +```powershell |
| 1038 | +$gistId = '6cad326836d38bd3a7ae' |
| 1039 | +$commentId = 1507813 |
| 1040 | +
|
| 1041 | +# If you don't specify -Force, it will prompt for confirmation before it will delete the comment |
| 1042 | +
|
| 1043 | +Remove-GitHubGistComment -Gist $gistId -Comment $commentId -Force |
| 1044 | +
|
| 1045 | +# or with the pipeline |
| 1046 | +Get-GitHubGist -Gist $gistId -Comment $commentId | Remove-GitHubGistComment -Force |
872 | 1047 | ```
|
873 | 1048 |
|
874 | 1049 | ----------
|
|
0 commit comments