Clone repos to local

Seto Elkahfi committed Jun 17, 2026 at 14:06 UTC a644a55d8a05212e69508e2878b9d60a3abfa908
2 files changed +46
app/controllers/api/v1/repos_controller.rb new
+45
@@ -0,0 +1,45 @@
1 +# frozen_string_literal: true
2 +
3 +module Api
4 + module V1
5 + # Lists the authenticated user's repositories hosted on sigit.si.
6 + #
7 + # This replaces the desktop app's old dependency on smbCloud platform
8 + # projects: siGit is a git app, so it lists the user's own sigit-si repos.
9 + class ReposController < Api::BaseController
10 + before_action :authenticate_token!
11 +
12 + # GET /api/v1/repos
13 + # Header: Authorization: Bearer <access_token>
14 + def index
15 + repos = current_user.repositories.order(updated_at: :desc)
16 + render json: repos.map { |repo| repo_json(repo) }, status: :ok
17 + end
18 +
19 + private
20 +
21 + def repo_json(repo)
22 + {
23 + id: repo.id,
24 + name: repo.name,
25 + full_name: repo.full_name,
26 + description: repo.description,
27 + default_branch: repo.default_branch,
28 + kind: repo.kind,
29 + is_private: repo.is_private,
30 + stars_count: repo.stars_count,
31 + initialized: repo.initialized?,
32 + updated_at: repo.updated_at,
33 + web_url: "#{request.base_url}/#{repo.full_name}",
34 + clone_url: "git@#{git_ssh_host}:#{repo.full_name}"
35 + }
36 + end
37 +
38 + # SSH host for git access (matches the clone command shown in the web UI).
39 + # Override per environment with SIGITSI_GIT_SSH_HOST.
40 + def git_ssh_host
41 + ENV.fetch("SIGITSI_GIT_SSH_HOST", "sigitsi.com")
42 + end
43 + end
44 + end
45 +end
config/routes.rb
+1
@@ -46,6 +46,7 @@ Rails.application.routes.draw do
46 post "auth/confirmation/resend", to: "confirmations#create"
47 get "me", to: "me#show"
48 delete "me", to: "me#destroy"
49 + get "repos", to: "repos#index"
50 end
51 end
52