MCPcopy Create free account
hub / github.com/cli/cli / guessGistName

Function guessGistName

pkg/cmd/gist/create/create.go:244–261  ·  view source on GitHub ↗
(files map[string]*shared.GistFile)

Source from the content-addressed store, hash-verified

242}
243
244func guessGistName(files map[string]*shared.GistFile) string {
245 filenames := make([]string, 0, len(files))
246 gistName := ""
247
248 re := regexp.MustCompile(`^gistfile\d+\.txt$`)
249 for k := range files {
250 if !re.MatchString(k) {
251 filenames = append(filenames, k)
252 }
253 }
254
255 if len(filenames) > 0 {
256 sort.Strings(filenames)
257 gistName = filenames[0]
258 }
259
260 return gistName
261}
262
263func createGist(client *http.Client, hostname, description string, public bool, files map[string]*shared.GistFile) (*shared.Gist, error) {
264 body := &shared.Gist{

Callers 3

Test_guessGistName_stdinFunction · 0.85
createRunFunction · 0.85

Calls

no outgoing calls

Tested by 2

Test_guessGistName_stdinFunction · 0.68