mirror of https://github.com/nyancrimew/goop.git
Do some minor clean up
This commit is contained in:
parent
f12d8ce393
commit
1b9d278cc9
|
@ -19,14 +19,11 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
const maxConcurrency = 60
|
||||
|
||||
var c = &fasthttp.Client{
|
||||
MaxConnsPerHost: utils.MaxInt(maxConcurrency+250, fasthttp.DefaultMaxConnsPerHost),
|
||||
TLSConfig: &tls.Config{
|
||||
|
@ -36,70 +33,6 @@ var c = &fasthttp.Client{
|
|||
MaxConnWaitTimeout: 10 * time.Second,
|
||||
}
|
||||
|
||||
var refPrefix = []byte{'r', 'e', 'f', ':'}
|
||||
var (
|
||||
packRegex = regexp.MustCompile(`(?m)pack-([a-f0-9]{40})\.pack`)
|
||||
objRegex = regexp.MustCompile(`(?m)(^|\s)([a-f0-9]{40})($|\s)`)
|
||||
)
|
||||
var (
|
||||
commonFiles = []string{
|
||||
".gitignore",
|
||||
".gitattributes",
|
||||
".gitmodules",
|
||||
".env",
|
||||
".git/COMMIT_EDITMSG",
|
||||
".git/description",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/commit-msg.sample",
|
||||
".git/hooks/post-commit.sample",
|
||||
".git/hooks/post-receive.sample",
|
||||
".git/hooks/post-update.sample",
|
||||
".git/hooks/pre-applypatch.sample",
|
||||
".git/hooks/pre-commit.sample",
|
||||
".git/hooks/pre-push.sample",
|
||||
".git/hooks/pre-rebase.sample",
|
||||
".git/hooks/pre-receive.sample",
|
||||
".git/hooks/prepare-commit-msg.sample",
|
||||
".git/hooks/update.sample",
|
||||
".git/index",
|
||||
".git/info/exclude",
|
||||
".git/objects/info/packs",
|
||||
}
|
||||
commonRefs = []string{
|
||||
".git/FETCH_HEAD",
|
||||
".git/HEAD",
|
||||
".git/ORIG_HEAD",
|
||||
".git/config",
|
||||
".git/info/refs",
|
||||
".git/logs/HEAD",
|
||||
".git/logs/refs/heads/master",
|
||||
".git/logs/refs/heads/main",
|
||||
".git/logs/refs/heads/dev",
|
||||
".git/logs/refs/heads/develop",
|
||||
".git/logs/refs/remotes/origin/HEAD",
|
||||
".git/logs/refs/remotes/origin/master",
|
||||
".git/logs/refs/remotes/origin/main",
|
||||
".git/logs/refs/remotes/origin/dev",
|
||||
".git/logs/refs/remotes/origin/develop",
|
||||
".git/logs/refs/stash",
|
||||
".git/packed-refs",
|
||||
".git/refs/heads/master",
|
||||
".git/refs/heads/main",
|
||||
".git/refs/heads/dev",
|
||||
".git/refs/heads/develop",
|
||||
".git/refs/remotes/origin/HEAD",
|
||||
".git/refs/remotes/origin/master",
|
||||
".git/refs/remotes/origin/main",
|
||||
".git/refs/remotes/origin/dev",
|
||||
".git/refs/remotes/origin/develop",
|
||||
".git/refs/stash",
|
||||
".git/refs/wip/wtree/refs/heads/master", //Magit
|
||||
".git/refs/wip/index/refs/heads/master", //Magit
|
||||
}
|
||||
)
|
||||
|
||||
func Clone(u, dir string, force bool) error {
|
||||
baseUrl := strings.TrimSuffix(u, "/")
|
||||
baseUrl = strings.TrimSuffix(baseUrl, "/HEAD")
|
||||
|
@ -293,10 +226,10 @@ func FetchGit(baseUrl, baseDir string) error {
|
|||
indexPath := utils.Url(baseDir, ".git/index")
|
||||
if utils.Exists(indexPath) {
|
||||
f, err := os.Open(indexPath)
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
var idx index.Index
|
||||
decoder := index.NewDecoder(f)
|
||||
if err := decoder.Decode(&idx); err != nil {
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package goop
|
||||
|
||||
import "regexp"
|
||||
|
||||
const maxConcurrency = 50
|
||||
|
||||
var refPrefix = []byte{'r', 'e', 'f', ':'}
|
||||
var (
|
||||
packRegex = regexp.MustCompile(`(?m)pack-([a-f0-9]{40})\.pack`)
|
||||
objRegex = regexp.MustCompile(`(?m)(^|\s)([a-f0-9]{40})($|\s)`)
|
||||
)
|
||||
var (
|
||||
commonFiles = []string{
|
||||
".gitignore",
|
||||
".gitattributes",
|
||||
".gitmodules",
|
||||
".env",
|
||||
".git/COMMIT_EDITMSG",
|
||||
".git/description",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/applypatch-msg.sample",
|
||||
".git/hooks/commit-msg.sample",
|
||||
".git/hooks/post-commit.sample",
|
||||
".git/hooks/post-receive.sample",
|
||||
".git/hooks/post-update.sample",
|
||||
".git/hooks/pre-applypatch.sample",
|
||||
".git/hooks/pre-commit.sample",
|
||||
".git/hooks/pre-push.sample",
|
||||
".git/hooks/pre-rebase.sample",
|
||||
".git/hooks/pre-receive.sample",
|
||||
".git/hooks/prepare-commit-msg.sample",
|
||||
".git/hooks/update.sample",
|
||||
".git/index",
|
||||
".git/info/exclude",
|
||||
".git/objects/info/packs",
|
||||
}
|
||||
commonRefs = []string{
|
||||
".git/FETCH_HEAD",
|
||||
".git/HEAD",
|
||||
".git/ORIG_HEAD",
|
||||
".git/config",
|
||||
".git/info/refs",
|
||||
".git/logs/HEAD",
|
||||
".git/logs/refs/heads/master",
|
||||
".git/logs/refs/heads/main",
|
||||
".git/logs/refs/heads/dev",
|
||||
".git/logs/refs/heads/develop",
|
||||
".git/logs/refs/remotes/origin/HEAD",
|
||||
".git/logs/refs/remotes/origin/master",
|
||||
".git/logs/refs/remotes/origin/main",
|
||||
".git/logs/refs/remotes/origin/dev",
|
||||
".git/logs/refs/remotes/origin/develop",
|
||||
".git/logs/refs/stash",
|
||||
".git/packed-refs",
|
||||
".git/refs/heads/master",
|
||||
".git/refs/heads/main",
|
||||
".git/refs/heads/dev",
|
||||
".git/refs/heads/develop",
|
||||
".git/refs/remotes/origin/HEAD",
|
||||
".git/refs/remotes/origin/master",
|
||||
".git/refs/remotes/origin/main",
|
||||
".git/refs/remotes/origin/dev",
|
||||
".git/refs/remotes/origin/develop",
|
||||
".git/refs/stash",
|
||||
".git/refs/wip/wtree/refs/heads/master", //Magit
|
||||
".git/refs/wip/index/refs/heads/master", //Magit
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue