CodeSession.fromSessionResource constructor

CodeSession.fromSessionResource(
  1. SessionResource session
)

Implementation

factory CodeSession.fromSessionResource(SessionResource session) {
  String? repoName;
  String? repoOwner;
  String? defaultBranch;
  final gitSource = session.sessionContext.sources
      .whereType<GitSource>()
      .firstOrNull;
  if (gitSource != null) {
    final parts = _parseRepoFromUrl(gitSource.url);
    if (parts != null) {
      repoOwner = parts.$1;
      repoName = parts.$2;
      defaultBranch = gitSource.revision;
    }
  }
  return CodeSession(
    id: session.id,
    title: session.title ?? 'Untitled',
    description: '',
    status: session.sessionStatus.name,
    repoName: repoName,
    repoOwner: repoOwner,
    defaultBranch: defaultBranch,
    createdAt: session.createdAt,
    updatedAt: session.updatedAt,
  );
}