Skip to content

Commit 79491d3

Browse files
authored
feat: Add GitHub user display name retrieval methods (#187)
1 parent a7d1cba commit 79491d3

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

plugins/titan-plugin-github/titan_plugin_github/clients/github_client.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,47 @@ def get_current_user(self) -> ClientResult[str]:
276276
error_code="API_ERROR"
277277
)
278278

279+
def get_user_display_name(self, login: str) -> ClientResult[str]:
280+
"""
281+
Get the display name of any GitHub user by login.
282+
283+
Returns the full name if configured, falls back to the login.
284+
285+
Args:
286+
login: GitHub username (login)
287+
288+
Returns:
289+
ClientResult[str] with display name (e.g. "Alex García" or "finxo")
290+
"""
291+
try:
292+
output = self._gh_network.run_command(["api", f"users/{login}", "-q", ".name // .login"])
293+
name = output.strip()
294+
return ClientSuccess(data=name, message="User display name retrieved")
295+
except Exception as e:
296+
return ClientError(
297+
error_message=f"Failed to get display name for {login}: {e}",
298+
error_code="API_ERROR"
299+
)
300+
301+
def get_current_user_display_name(self) -> ClientResult[str]:
302+
"""
303+
Get the display name of the authenticated GitHub user.
304+
305+
Returns the full name if configured, falls back to the username login.
306+
307+
Returns:
308+
ClientResult[str] with display name (e.g. "Alex García" or "finxo")
309+
"""
310+
try:
311+
output = self._gh_network.run_command(["api", "user", "-q", ".name // .login"])
312+
name = output.strip()
313+
return ClientSuccess(data=name, message="Current user display name retrieved")
314+
except Exception as e:
315+
return ClientError(
316+
error_message=f"Failed to get current user display name: {e}",
317+
error_code="API_ERROR"
318+
)
319+
279320
def get_default_branch(self) -> ClientResult[str]:
280321
"""
281322
Get the default branch for the repository.

0 commit comments

Comments
 (0)