first push
This commit is contained in:
commit
cc7b14ae4d
|
@ -0,0 +1,2 @@
|
|||
*.fasl
|
||||
/bin
|
|
@ -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)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
# git-migrate
|
||||
### _ava fox_
|
||||
|
||||
This is a project to do ... something.
|
||||
|
||||
## License
|
||||
|
||||
NPLv1+
|
||||
|
|
@ -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))
|
||||
|
||||
|
||||
|
|
@ -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))
|
|
@ -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))
|
Loading…
Reference in New Issue