first push

This commit is contained in:
Zac 2019-11-24 16:52:00 -05:00
commit cc7b14ae4d
6 changed files with 97 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.fasl
/bin

19
Makefile Normal file
View File

@ -0,0 +1,19 @@
LISPS = ros sbcl clisp cmucl ccl
CMDS = --eval "(ql:quickload :remote-rename)" --eval "(asdf:make :remote-rename)" --eval "(quit)"
ifeq ($(OS),Windows_NT)
LISP := $(foreach lisp,$(LISPS), \
$(shell where $(lisp)) \
$(if $(.SHELLSTATUS),$(strip $(lisp)),))
else
LISP := $(foreach lisp,$(LISPS), \
$(if $(findstring $(lisp),"$(shell which $(lisp) 2>/dev/null)"), $(strip $(lisp)),))
endif
ifeq ($(LISP),)
$(error "No lisps found")
endif
all:
$(LISP) $(CMDS)

9
README.md Normal file
View File

@ -0,0 +1,9 @@
# git-migrate
### _ava fox_
This is a project to do ... something.
## License
NPLv1+

21
package.lisp Normal file
View File

@ -0,0 +1,21 @@
;;;; package.lisp
(defpackage #:remote-rename
(:use #:cl)
(:import-from :legit
:git-location-p
:remotes
:git-remote
:init)
(:import-from :str
:containsp
:replace-all)
(:import-from :cl-fad
:walk-directory)
(:import-from :uiop
:command-line-arguments
:directory-exists-p
:directory-pathname-p))

19
remote-rename.asd Normal file
View File

@ -0,0 +1,19 @@
;;;; git-migrate.asd
(asdf:defsystem #:remote-rename
:description "migrate a local git repo to a new username"
:author "ava fox"
:license "NPLv1+"
:version "0.1"
:serial t
:depends-on (#:cl-cwd #:legit #:unix-opts #:cl-fad #:str)
:components ((:file "package")
(:file "remote-rename"))
:build-operation "program-op"
:build-pathname "bin/remote-rename"
:entry-point "remote-rename::main")
#+sb-core-compression
(defmethod asdf:perform ((o asdf:image-op) (c asdf:system))
(uiop:dump-image (asdf:output-file o c) :executable t :compression t))

27
remote-rename.lisp Normal file
View File

@ -0,0 +1,27 @@
;;;; git-migrate.lisp
(in-package #:remote-rename)
(defvar *old-acct*)
(defvar *new-acct*)
(defun main ()
(unless (= (length (command-line-arguments)) 3)
(quit 1 "not enough arguments" "remote-rename DIRECTORY OLD-ACCOUNT NEW-ACCOUNT"))
(destructuring-bind (directory old-account new-account) (command-line-arguments)
(setf *old-acct* old-account)
(setf *new-acct* new-account)
(if (directory-exists-p directory)
(walk-directory directory #'maybe-change-git-remote :directories :breadth-first)
(quit 1 "directory does not exist"))))
(defun maybe-change-git-remote (item)
(when (and (directory-pathname-p item) (git-location-p item))
(let ((repo (init item)))
(setf (remotes repo)
(loop for remote in (remotes repo)
collect `(,(car remote) . ,(replace-all *old-acct* *new-acct* (cdr remote))))))))
(defun quit (code &rest messages)
(format t "~{~a~%~}" messages)
(uiop:quit code))