Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Commit

Permalink
fix: assumed "master" as default branch (#370)
Browse files Browse the repository at this point in the history
* Disable nlreturn linter

`nlreturn` checks for a new line before return and branch statements to increase code clarity. This project does not adhere to this convention and fails `make lint` without this change.

* Change test to specify master branch

fribmendes/geometry changed its default branch to "main", and it no longer has a submodule to test on that branch. The master branch is still there though and has the async submodule to test, so this commit specifies that branch.

* Fix master as assumed branch (#369)

Instead of assuming "master" is always the branch we want, these changes allow for taking whatever default branch the GitHub repo specifies. This supports initiatives like the move to "main" as the default branch name.

* Add mattmc3's dotfiles to list
  • Loading branch information
mattmc3 committed Sep 3, 2020
1 parent e33e3ac commit fe5b75a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -24,7 +24,7 @@ cover: test

# Run all the linters
lint:
./bin/golangci-lint run --disable godox --disable wsl --disable gomnd --disable testpackage --disable gofumpt --disable godot --enable-all ./...
./bin/golangci-lint run --disable godox --disable wsl --disable gomnd --disable testpackage --disable gofumpt --disable godot --disable nlreturn --enable-all ./...
.PHONY: lint

# Run all the tests and code checks
Expand Down
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -40,6 +40,7 @@ Documentation can be found at https://getantibody.github.io
- @davidkna's [dotfiles](https://github.com/davidkna/dotfiles);
- @sobolevn's [dotfiles](https://github.com/sobolevn/dotfiles);
- @jesseleite's [dotfiles](https://github.com/jesseleite/dotfiles);
- @mattmc3's [dotfiles](https://github.com/mattmc3/zdotdir/tree/antibody)
- and probably [many others](https://github.com/search?q=antibody&type=Code);

## Thanks
Expand Down
28 changes: 17 additions & 11 deletions project/git.go
Expand Up @@ -27,7 +27,7 @@ func NewClonedGit(home, folderName string) Project {
folderPath := filepath.Join(home, folderName)
version, err := branch(folderPath)
if err != nil {
version = "master"
version = ""
}
url := folder.ToURL(folderName)
return gitProject{
Expand All @@ -45,7 +45,7 @@ const (
// NewGit A git project can be any repository in any given branch. It will
// be downloaded to the provided cwd
func NewGit(cwd, line string) Project {
version := "master"
version := ""
inner := ""
parts := strings.Split(line, " ")
for _, part := range parts {
Expand Down Expand Up @@ -91,13 +91,16 @@ func (g gitProject) Download() error {
defer lock.Unlock()
if _, err := os.Stat(g.folder); os.IsNotExist(err) {
// #nosec
var cmd = exec.Command("git", "clone",
args := []string{
"clone",
"--recursive",
"--depth", "1",
"-b", g.Version,
g.URL,
g.folder,
)
}
if g.Version != "" {
args = append(args, "-b", g.Version)
}
args = append(args, g.URL, g.folder)
var cmd = exec.Command("git", args...)
cmd.Env = gitCmdEnv

if bts, err := cmd.CombinedOutput(); err != nil {
Expand All @@ -115,12 +118,15 @@ func (g gitProject) Update() error {
return err
}
// #nosec
cmd := exec.Command(
"git", "pull",
args := []string{
"pull",
"--recurse-submodules",
"origin",
g.Version,
)
}
if g.Version != "" {
args = append(args, g.Version)
}
cmd := exec.Command("git", args...)
cmd.Env = gitCmdEnv

cmd.Dir = g.folder
Expand Down
2 changes: 1 addition & 1 deletion project/git_test.go
Expand Up @@ -36,7 +36,7 @@ func TestDownloadAllKinds(t *testing.T) {

func TestDownloadSubmodules(t *testing.T) {
var home = home()
var proj = NewGit(home, "fribmendes/geometry")
var proj = NewGit(home, "fribmendes/geometry branch:master")
var module = filepath.Join(proj.Path(), "lib/zsh-async")
require.NoError(t, proj.Download())
require.NoError(t, proj.Update())
Expand Down

0 comments on commit fe5b75a

Please sign in to comment.