Skip to content

Commit b2ffe1a

Browse files
committed
Basics working (no unpacking)
1 parent 7ddf360 commit b2ffe1a

File tree

431 files changed

+256002
-44
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

431 files changed

+256002
-44
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
*.out
1313

1414
.idea
15-
15+
/gitjacker
16+
/bin

.travis.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
language: go
2+
go:
3+
- 1.15
4+
env:
5+
global:
6+
- secure: "cmShOYuHjWU915Jp95Cr+rK1BKZXYTcX9BN8VS1cVugdKg/lH5JZTkm26vL+aNBGzjUHx7e88Sx5cSUB4ysBnu5CsUUS1lytVI2xO3cZ599iujnA6YqtYItmrQwV+LeFKqK0P6/gKLskb2Pwzt1NQDFdGMUJs/A2Ao7kN8VkozFsnUohUuQkuBr/afQjlVxLRIZlR5LFbbLPFhMU6i1RddAMcOvVh3SsQBPAVqmtSz0hH2WXMRgTdWoref1T4ecFK+dpuY/ajSfA3RqnycFFo6y2AAI09VB031Mq40O8ey5QxC3Hvxxu0F9BSUH3Xnt6ha2tVsBGOTte8RvHVLLRAnVmrRDkXB3wtfSq+x5ijrxMOXnbEXwB4pPFBac21sJAFNJRHt+L+2Al2P2BlDv8iCHEe0/ieN3et1weQUbCN/2+Rg+qobV/espPh8iYe1bPfAHg/Ia3Wok+A48JtuvkpqsB2LCqGqb5hft9rbNROJ8a8cPoRKC28n4s74JkkMHJDFb43Ygd8LQ/sM/mJw9z37SMjpwF/kypUqBsZ4yKbPJwFCoq0180ykCvdds16hS9wDb89uvY6A5Pv2LuTbmRRgJInDI+AUgclrHbj9gaxyv+ic5rod9GDNIKDddNSMWjdL+p0jtz68SzbF/WKl1yGHk2MmDa/C875Yi7J8D8fdQ="
7+
jobs:
8+
include:
9+
- stage: test
10+
name: Run tests
11+
script:
12+
- make test
13+
- stage: build
14+
script:
15+
- make build
16+
deploy:
17+
provider: releases
18+
skip_cleanup: true
19+
name: "$TRAVIS_TAG"
20+
edge: true
21+
file:
22+
- bin/darwin/gitjacker-darwin-amd64
23+
- bin/linux/gitjacker-linux-amd64
24+
- bin/windows/gitjacker-windows-amd64.exe
25+
on:
26+
repo: liamg/gitjacker
27+
tags: true

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
default: build
2+
3+
.PHONY: test
4+
test:
5+
go test -mod=vendor -v ./...
6+
7+
.PHONY: build
8+
build:
9+
./scripts/build.sh

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# gitjacker
2+
3+
[![Travis Build Status](https://travis-ci.org/liamg/gitjacker.svg?branch=master)](https://travis-ci.org/liamg/gitjacker)
4+
25
Steal source git repositories from misconfigured websites
6+
7+
## Installation
8+
9+
```bash
10+
curl -s "https://raw.githubusercontent.com/liamg/gitjacker/master/scripts/install.sh" | bash
11+
```
12+
13+
...or grab a [precompiled binary](https://github.com/liamg/gitjacker/releases).

cmd/gitjacker/main.go

Lines changed: 78 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,20 @@ import (
88
"os/exec"
99
"strings"
1010

11+
"github.com/sirupsen/logrus"
12+
13+
"github.com/liamg/gitjacker/internal/app/version"
1114
"github.com/liamg/gitjacker/internal/pkg/gitjacker"
15+
"github.com/liamg/tml"
1216
"github.com/spf13/cobra"
1317
)
1418

1519
var outputDir string
20+
var verbose bool
1621

1722
func main() {
1823

24+
rootCmd.Flags().BoolVarP(&verbose, "verbose", "v", verbose, "Enable verbose logging")
1925
rootCmd.Flags().StringVarP(&outputDir, "output-dir", "o", outputDir, "Directory to output retrieved git repository - defaults to a temporary directory")
2026

2127
if err := rootCmd.Execute(); err != nil {
@@ -32,6 +38,15 @@ More information at https://github.com/liamg/gitjacker`,
3238
Args: cobra.ExactArgs(1),
3339
RunE: func(cmd *cobra.Command, args []string) error {
3440

41+
_ = tml.Printf(`<red>
42+
██████ ██ ████████ ██ █████ ██████ ██ ██ ███████ ██████
43+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
44+
██ ███ ██ ██ ██ ███████ ██ █████ █████ ██████
45+
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
46+
██████ ██ ██ █████ ██ ██ ██████ ██ ██ ███████ ██ ██
47+
https://github.com/liamg/gitjacker %9s
48+
`, version.Version)
49+
3550
rawURL := args[0]
3651
rawURL = strings.TrimSuffix(rawURL, "/.git/")
3752
rawURL = strings.TrimSuffix(rawURL, "/.git")
@@ -56,15 +71,74 @@ More information at https://github.com/liamg/gitjacker`,
5671
if err != nil {
5772
return fmt.Errorf("failed to start git: %w - please check it is installed", err)
5873
}
74+
versionParts := strings.Split(string(versionData), " ")
75+
version := strings.TrimSpace(versionParts[len(versionParts)-1])
76+
77+
if verbose {
78+
logrus.SetLevel(logrus.DebugLevel)
79+
}
5980

60-
version := strings.Split(string(versionData), " ")
61-
_ = version // TODO output this
81+
tml.Printf(`
82+
Target: <yellow>%s</yellow>
83+
Local Git: %s
84+
Output Dir: %s
85+
`, u.String(), version, outputDir)
6286

63-
if err := gitjacker.New(u, outputDir).Run(); err != nil {
87+
if !verbose {
88+
_ = tml.Printf("\n<yellow>Gitjacking in progress...")
89+
}
90+
91+
summary, err := gitjacker.New(u, outputDir).Run()
92+
if err != nil {
93+
if !verbose {
94+
fmt.Printf("\x1b[2K\r")
95+
}
6496
return err
6597
}
6698

67-
fmt.Printf("Output directory: %s\n", outputDir)
99+
if !verbose {
100+
_ = tml.Printf("\x1b[2K\r<yellow>Operation complete.\n")
101+
}
102+
103+
status := "FAILED"
104+
switch summary.Status {
105+
case gitjacker.StatusPartialSuccess:
106+
status = tml.Sprintf("<yellow>Partial Success")
107+
case gitjacker.StatusSuccess:
108+
status = tml.Sprintf("<green>Success")
109+
}
110+
111+
var remoteStr string
112+
for _, remote := range summary.Config.Remotes {
113+
remoteStr = fmt.Sprintf("%s\n - %s: %s", remoteStr, remote.Name, remote.URL)
114+
}
115+
116+
var branchStr string
117+
for _, branch := range summary.Config.Branches {
118+
branchStr = fmt.Sprintf("%s\n - %s (%s)", branchStr, branch.Name, branch.Remote)
119+
}
120+
121+
_ = tml.Printf(`
122+
Status: %s
123+
Retrieved Objects: <green>%d</green>
124+
Missing Objects: <red>%d</red>
125+
Pack Data Listed: %t
126+
Repository: %s
127+
Remotes: %s
128+
Branches: %s
129+
130+
You can find the retrieved repository data in <blue>%s</blue>
131+
132+
`,
133+
status,
134+
len(summary.FoundObjects),
135+
len(summary.MissingObjects),
136+
summary.PackInformationAvailable,
137+
summary.Config.RepositoryName,
138+
remoteStr,
139+
branchStr,
140+
summary.OutputDirectory,
141+
)
68142

69143
return nil
70144
},

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ go 1.15
44

55
require (
66
github.com/go-git/go-git v4.7.0+incompatible // indirect
7+
github.com/liamg/tml v0.3.0
78
github.com/magiconair/properties v1.8.0
89
github.com/sergi/go-diff v1.1.0 // indirect
10+
github.com/sirupsen/logrus v1.2.0
911
github.com/spf13/cobra v1.0.0
1012
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
1113
)

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,15 @@ github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd h1:Coekwdh0v
6161
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
6262
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
6363
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
64+
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
6465
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
6566
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
6667
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
6768
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
6869
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
6970
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
71+
github.com/liamg/tml v0.3.0 h1:Qz+R+E3BH07IgflYyB4dLijKZ+mZcKJEuC5pTNDWShc=
72+
github.com/liamg/tml v0.3.0/go.mod h1:0h4EAV/zBOsqI91EWONedjRpO8O0itjGJVd+wG5eC+E=
7073
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
7174
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
7275
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
@@ -95,6 +98,7 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
9598
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
9699
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
97100
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
101+
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
98102
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
99103
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
100104
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=

internal/app/version/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package version
2+
3+
var Version string = "v0.0.0"

0 commit comments

Comments
 (0)