Skip to content

Commit ddcd84a

Browse files
authored
Merge pull request #5 from Bobonium/initial_release
initial release changes
2 parents 2b8a76d + 41e8d4e commit ddcd84a

File tree

4 files changed

+132
-6
lines changed

4 files changed

+132
-6
lines changed

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## [Unreleased] - TBD
2+
- no changes
3+
4+
## [1.0.0] - 2019-10-27
5+
- initial release
6+
- MIT License
7+
- includes README.md and CHANGELOG.md
8+
- includes Makefile for test and install
9+
- `make all`
10+
- `make test`
11+
- `make install`
12+
- initial functionality includes
13+
- parsing of `yaml`-like .gitfile
14+
- source
15+
- path
16+
- version
17+
- supports comments with `#`
18+
- cli paramters for
19+
- help (-h/--help)
20+
- configuring .gitfile location (-f/--gitfile)
21+
- configuring default clone path (-p/--default-clone-path)

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
all:
2+
${MAKE} test
3+
${MAKE} install
4+
15
test:
2-
docker-compose up test
6+
docker-compose up --exit-code-from test test
37

48
install:
5-
cp ./gitfile.sh /usr/local/bin/gitfile
9+
cp ./gitfile.sh /usr/local/bin/gitfile

README.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Gitfile
2+
3+
Gitfile is a MIT-Licensed Bash-script written in less than 100 lines to manage git repositores.
4+
5+
Originally written as a replacement for terraform module managers like https://github.com/coretech/terrafile and https://github.com/devopsmakers/xterrafile
6+
7+
Main reasons for the rewrite were:
8+
- both written in Go with dependencies for a job that can be done in bash in less than 100 lines
9+
- both always delete and re-clone the repository on execution
10+
- both always delete the path recursively (they seriously delete your working directory if it's part of the path) which makes it impossible for directory structures like:
11+
```shell script
12+
workspace
13+
├── moduleA
14+
│   ├── main.tf
15+
├── moduleB
16+
│   ├── main.tf
17+
| ├── moduleA.tf
18+
├── moduleC
19+
│   ├── main.tf
20+
│   ├── moduleA.tf
21+
│   ├── moduleB.tf
22+
```
23+
24+
`Gitfile` ended up beeing a more general approach that enables git management in general
25+
26+
27+
## Features
28+
- doesn't delete your directories (looking at you `terrafile` tools -.-*)
29+
- clones repository only if it hasn't been cloned already
30+
- incremental changes are retrieved with fetch/checkout/pull
31+
- fetch/checkout/pull are only executed if there are no changes in the local repository
32+
- updates remote ULR if it changes (i.e. repo moved from github to self hosted domain)
33+
34+
## Usage in automation
35+
36+
In most cases you should be able to use the gitfile locally and in automation in exactly the same way.
37+
Nonetheless there are some use cases where you might prefer to Download your repository in automation using HTTPS instead of SSH or vice versa.
38+
Simply re-configure git in your pipeline to switch from http cloning to ssh cloning:
39+
```shell script
40+
git config --global url.ssh://[email protected]/.insteadOf https://github.com/
41+
```
42+
43+
## Install
44+
45+
```shell script
46+
git clone https://github.com/Bobonium/gitfile.git
47+
cd gitfile
48+
make install
49+
```
50+
51+
or alternatively:
52+
```shell script
53+
curl -L https://raw.githubusercontent.com/Bobonium/gitfile/master/gitfile.sh > /usr/local/bin/gitfile
54+
```
55+
56+
#### dependencies:
57+
- git
58+
- openssh-client
59+
- make (for test/install)
60+
61+
62+
## Use
63+
64+
#### Command overview
65+
66+
```shell script
67+
#quick-start
68+
cd ~/workspace/github/Bobonium/gitfile/
69+
gitfile
70+
```
71+
72+
```shell script
73+
#print help text
74+
gitfile -h #--help
75+
#path/filename to parse as gitfile (default: ./.gitfile)
76+
gitfile -f /path/to/gitfile #--gitfile ->
77+
#path to store repos without explicit `path` (default: ./)
78+
gitfile -p /default/clone/path #--default-clone-path
79+
```
80+
81+
#### .gitfile format
82+
83+
This is only a YAML-like format! gitfile does not use a full blown yaml parser, but instead only implemented the minimal requirements through some shell commands.
84+
Feel free to create an Issue/Pull request if you find a problem with the parsing (or anything else of course).
85+
86+
```yaml
87+
#required: repo will be cloned into dir with this name
88+
gitfile:
89+
#required: clone URL (can be either http(s) or ssh)
90+
source: "https://github.com/Bobonium/gitfile.git"
91+
#optional: path to clone the repository into (default taken from gitfile command)
92+
#relative path values are always relative to the path of the .gitfile
93+
path: ~/workspace/github/Bobonium/
94+
#optional: version to checkout (defaults to master)
95+
#tags, branch names and commit hases are all valid values
96+
#if you can run `git checkout $VERSION` it's valid
97+
version: master
98+
```
99+
100+
#### Release Cycle:
101+
102+
Master branch will always be the current release; if it's good enough to merge, it's good enough to be released

docker-compose.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ version: "2"
33
services:
44
test:
55
image: bash:5
6-
working_dir: /root/workspace/
6+
working_dir: /root/workspace/gitfile/
77
volumes:
88
- ~/.ssh/:/root/.ssh/
9-
- ./:/root/workspace/github/Bobonium/gitfile/
10-
- ./gitfile.sh:/usr/local/bin/gitfile
9+
- ./:/root/workspace/gitfile/
1110
command:
1211
- bash
1312
- -c
14-
- "apk update > /dev/null 2>&1 && apk add git openssh-client > /dev/null 2>&1 && gitfile -f ./github/Bobonium/gitfile/.gitfile"
13+
- "apk update > /dev/null 2>&1 && apk add git openssh-client make > /dev/null 2>&1 && make install && gitfile -f ./.gitfile"

0 commit comments

Comments
 (0)