-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-klone-setup.scm
executable file
·102 lines (95 loc) · 4.93 KB
/
git-klone-setup.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/guile3.0 \
-e main -s
!#
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Anne Summers ;;
;; ukulanne@gmail.com ;;
;; May 4, 2017 ;;
;; Clone new repo ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Time-stamp: <2023-01-03 20:02:52 panda>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This program is free software: you can redistribute it and/or modify ;;
;; it under the terms of the GNU Lesser General Public License as published by ;;
;; the Free Software Foundation, either version 3 of the License, or ;;
;; (at your option) any later version. ;;
;; ;;
;; This program 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 Lesser General Public License for more details. ;;
;; ;;
;; You should have received a copy of the GNU Lesser General Public License ;;
;; along with this program. If not, see <https://www.gnu.org/licenses/>. ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(use-modules (ice-9 getopt-long))
(define VERSION "0.75")
(define GIT " git@github.com:")
(define GIT-PATH (string-append "/home/panda/src/git/"))
(define NPM #t)
(define ORG "ukulanne")
(define MODULE "git-klone-setup")
(define BRANCH "dev")
(define MODULE-PATH "")
(define GIT-COMMAND "")
(define TAG #f)
;;(define sed-to-ssh "sed -i 's/https:\\/\\/github.ibm.com\\/AIX-Tools-Team\\//git@github.ibm.com:AIX-Tools-Team\\//' .gitmodules")
;;(define sed-to-https "sed -i 's/git@github.ibm.com:AIX-Tools-Team/https:\\/\\/github.ibm.com\\/AIX-Tools-Team/' .gitmodules")
(define HELP "\
Usage: git-klone-setup.scm [options]
Clones a module from github and creates a backup of current version
-m, --module Module to clone.
-o, --org Organization to use (aixtools default)
-b, --branch Branch to use.
-t, --tag Tag to use for backup directory
-v, --version Display version.
-h, --help Display this help.
Copyright (C) 2017-2023 Anne Summers <ukulanne@gmail.com>
This is free software released under the GNU LGPL 3,
and you are welcome to redistribute it under certain conditions.
Please see <https://www.gnu.org/licenses/ for more information.\n")
(define (main args)
(let* ((option-spec '((module (single-char #\m) (value #t))
(org (single-char #\o) (value #t))
(branch (single-char #\b) (value #t))
(tag (single-char #\t) (value #t))
(version (single-char #\v) (value #f))
(help (single-char #\h) (value #f))))
(options (getopt-long args option-spec))
(module-set (option-ref options 'module #f))
(org-set (option-ref options 'org #f))
(branch-set (option-ref options 'branch #f))
(tag-set (option-ref options 'tag #f))
(help-wanted (option-ref options 'help #f))
(version-wanted (option-ref options 'version #f)))
(if (or version-wanted help-wanted)
(begin
(if version-wanted
(display (string-append "git-klone-setup.scm " VERSION "\nAnne Summers<ukulanne@gmail.com>\n")))
(if help-wanted
(display HELP)))
(begin
(if module-set (set! MODULE module-set))
(if org-set (set! ORG org-set))
(if branch-set (set! BRANCH branch-set))
(if tag-set (set! TAG tag-set))
(set! MODULE-PATH (string-append GIT-PATH MODULE))
(set! GIT-COMMAND (string-append "git clone --branch=" BRANCH GIT ORG "/" MODULE ".git"))
(if (file-exists? MODULE-PATH)
(rename-file MODULE-PATH
(string-append MODULE-PATH "-"
(if TAG (string-append TAG "-") "")
(strftime "%Y%m%d-%H:%M:%S" (localtime (current-time))))))
(system GIT-COMMAND)
;; (if (file-exists? (string-append MODULE-PATH "/.gitmodules"))
;; (system (string-append "cd " MODULE-PATH " && " sed-to-ssh)))
(system (string-append "cd " MODULE-PATH " && git submodule update --init --recursive --remote"))
;;(if (file-exists? (string-append MODULE-PATH "/.gitmodules"))
;; (system (string-append "cd " MODULE-PATH " && " sed-to-https)))
(if (file-exists? (string-append MODULE-PATH "/package.json"))
(system (string-append "cd " MODULE-PATH " && npm install")))
(system (string-append "cd " MODULE-PATH))
)
)
)
)