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

Method CurrentUsername

pkg/cmd/status/status.go:214–231  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

212}
213
214func (s *StatusGetter) CurrentUsername() (string, error) {
215 s.usernameMu.Lock()
216 defer s.usernameMu.Unlock()
217
218 if s.currentUsername != "" {
219 return s.currentUsername, nil
220 }
221
222 cachedClient := s.CachedClient(time.Hour * 48)
223 cachingAPIClient := api.NewClientFromHTTP(cachedClient)
224 currentUsername, err := api.CurrentLoginName(cachingAPIClient, s.hostname())
225 if err != nil {
226 return "", fmt.Errorf("failed to get current username: %w", err)
227 }
228
229 s.currentUsername = currentUsername
230 return currentUsername, nil
231}
232
233func (s *StatusGetter) ActualMention(commentURL safeurl.SafeURL) (string, error) {
234 currentUsername, err := s.CurrentUsername()

Callers 2

ActualMentionMethod · 0.95
LoadEventsMethod · 0.95

Calls 3

CachedClientMethod · 0.95
hostnameMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected