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
+45
new file mode 100644
index 0000000..3e0cc1f
--- /dev/null
+++ b/app/controllers/api/v1/repos_controller.rb
@@ -0,0 +1,45 @@
+# frozen_string_literal: true
+
+module Api
+ module V1
+ # Lists the authenticated user's repositories hosted on sigit.si.
+ #
+ # This replaces the desktop app's old dependency on smbCloud platform
+ # projects: siGit is a git app, so it lists the user's own sigit-si repos.
+ class ReposController < Api::BaseController
+ before_action :authenticate_token!
+
+ # GET /api/v1/repos
+ # Header: Authorization: Bearer <access_token>
+ def index
+ repos = current_user.repositories.order(updated_at: :desc)
+ render json: repos.map { |repo| repo_json(repo) }, status: :ok
+ end
+
+ private
+
+ def repo_json(repo)
+ {
+ id: repo.id,
+ name: repo.name,
+ full_name: repo.full_name,
+ description: repo.description,
+ default_branch: repo.default_branch,
+ kind: repo.kind,
+ is_private: repo.is_private,
+ stars_count: repo.stars_count,
+ initialized: repo.initialized?,
+ updated_at: repo.updated_at,
+ web_url: "#{request.base_url}/#{repo.full_name}",
+ clone_url: "git@#{git_ssh_host}:#{repo.full_name}"
+ }
+ end
+
+ # SSH host for git access (matches the clone command shown in the web UI).
+ # Override per environment with SIGITSI_GIT_SSH_HOST.
+ def git_ssh_host
+ ENV.fetch("SIGITSI_GIT_SSH_HOST", "sigitsi.com")
+ end
+ end
+ end
+end
config/routes.rb
+1
index c73c107..64881cc 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -46,6 +46,7 @@ Rails.application.routes.draw do
post "auth/confirmation/resend", to: "confirmations#create"
get "me", to: "me#show"
delete "me", to: "me#destroy"
+ get "repos", to: "repos#index"
end
end