From 093ffa5fbf7143f4668bb0a3dc9659a5cc836e12 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sat, 17 Jun 2023 17:20:29 +1000 Subject: Moving things one level deeper To ease gnu stow usage. Now we can do stow -t ~ emacs --- emacs/.emacs.d/lisp/my/my-gitlab.el | 61 +++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 emacs/.emacs.d/lisp/my/my-gitlab.el (limited to 'emacs/.emacs.d/lisp/my/my-gitlab.el') diff --git a/emacs/.emacs.d/lisp/my/my-gitlab.el b/emacs/.emacs.d/lisp/my/my-gitlab.el new file mode 100644 index 0000000..a25533f --- /dev/null +++ b/emacs/.emacs.d/lisp/my/my-gitlab.el @@ -0,0 +1,61 @@ +;;; my-gitlab.el -- gitlab client -*- lexical-binding: t -*- + +;; Copyright (C) 2023 Free Software Foundation. + +;; Author: Yuchen Pei +;; Package-Requires: ((emacs "28.2")) + +;; This file is part of dotfiles. + +;; dotfiles is free software: you can redistribute it and/or modify it under +;; the terms of the GNU Affero General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; dotfiles is distributed in the hope that it will be useful, but WITHOUT +;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General +;; Public License for more details. + +;; You should have received a copy of the GNU Affero General Public +;; License along with dotfiles. If not, see . + +;;; Commentary: + +;; gitlab client. + +;;; Code: + + +(defun my-get-gitlab-project-id (url) + (with-current-buffer (url-retrieve-synchronously + (replace-regexp-in-string "\\.git$" "" url)) + (goto-char (point-min)) + (when (re-search-forward "Project ID: \\([0-9]+\\)" nil t) + (match-string 1)))) + +(defun my-grok-gitlab (url) + (when-let* ((urlobj (url-generic-parse-url url)) + (project-id (my-get-gitlab-project-id url))) + (with-current-buffer + (url-retrieve-synchronously + (concat (url-type urlobj) "://" (url-host urlobj) + "/api/v4/projects/" project-id)) + (set-buffer-multibyte t) + (my-delete-http-header) + (my-grok-gitlab-make-info (json-read))))) + +(defun my-grok-gitlab-make-info (raw) + (list (cons "Title" (alist-get 'name raw)) + (cons "Description" (my-clean-property-value + (alist-get 'description raw))) + (cons "Source" (alist-get 'web_url raw)) + (cons "Subject" (string-join + (alist-get 'tag_list raw) ", ")) + (cons "Released" (substring (alist-get 'created_at raw) 0 10)) + (cons "Last-activity" (substring + (alist-get 'last_activity_at raw) 0 10)) + (cons "Developers" (alist-get 'name (alist-get 'namespace raw))))) + +(provide 'my-gitlab) +;;; my-gitlab.el ends here -- cgit v1.2.3