Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Shorter apply output, json dump available on verbose
* Rounded execution times

### Fixed

* Fix `Empty git repository` bug
* Fix wrong used `path` import for file paths

## [0.4.3] - 2026-07-30

### Changed
Expand Down
5 changes: 2 additions & 3 deletions internal/cmd/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cmd
import (
"errors"
"os"
"path"
"path/filepath"
"repo/internal/config"
h "repo/internal/hoster"
Expand Down Expand Up @@ -129,8 +128,8 @@ func processDir(dirReposRoot string, hoster h.Hoster, counter *int32, total int,
func move(dirReposRoot string, dirRepository string, dirTarget string) error {
dirRepoRelative := getRelativRepoDir(dirRepository, dirReposRoot)
dirAbsSource := dirRepository
dirAbsTarget := path.Join(dirReposRoot, dirTarget)
dirAbsTargetRepository := path.Join(dirReposRoot, dirTarget, dirRepoRelative)
dirAbsTarget := filepath.Join(dirReposRoot, dirTarget)
dirAbsTargetRepository := filepath.Join(dirReposRoot, dirTarget, dirRepoRelative)

// check & prepare target
// create if not exists
Expand Down
6 changes: 3 additions & 3 deletions internal/cmd/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cmd

import (
"os"
"path"
"path/filepath"
"repo/internal/config"
"repo/internal/gitclient"
h "repo/internal/hoster"
Expand Down Expand Up @@ -67,9 +67,9 @@ func filterExisting(dirReposRoot string, repos []h.HosterRepository) (result []h
var dirRepository string
switch config.Values.Options.Style {
case config.StyleFlat:
dirRepository = path.Join(dirReposRoot, r.Path)
dirRepository = filepath.Join(dirReposRoot, r.Path)
case config.StyleRecursive:
dirRepository = path.Join(dirReposRoot, r.PathWithNamespace)
dirRepository = filepath.Join(dirReposRoot, r.PathWithNamespace)
}

_, err := os.Stat(dirRepository)
Expand Down
7 changes: 3 additions & 4 deletions internal/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io/fs"
"math"
"os"
"path"
"path/filepath"
h "repo/internal/hoster"
"repo/internal/model"
Expand Down Expand Up @@ -63,7 +62,7 @@ func validateArgGitDir(argIndex int, repoParent bool, repoRoot bool) cobra.Posit
if !util.ExistsDir(repoPath) {
return errors.New(msg + " (directory does not exist)")
}
condParent := repoParent && util.ExistsDir(path.Join(repoPath, ".git"))
condParent := repoParent && util.ExistsDir(filepath.Join(repoPath, ".git"))
condRoot := repoRoot

if !condParent && !condRoot {
Expand All @@ -77,7 +76,7 @@ func validateArgGitDir(argIndex int, repoParent bool, repoRoot bool) cobra.Posit
// collect them and return the array
func collectGitDirs(root string, hoster h.Hoster) (result []model.RepoDir, err error) {

ignored := []string{path.Join(root, dirArchived), path.Join(root, dirRemoved)}
ignored := []string{filepath.Join(root, dirArchived), filepath.Join(root, dirRemoved)}

walk := func(dir string, d fs.DirEntry, e error) error {
if !d.IsDir() {
Expand All @@ -88,7 +87,7 @@ func collectGitDirs(root string, hoster h.Hoster) (result []model.RepoDir, err e
return fs.SkipDir
}

if util.ExistsDir(path.Join(dir, ".git")) { // check if given path is git-repository
if util.ExistsDir(filepath.Join(dir, ".git")) { // check if given path is git-repository
repo, err := model.MakeRepoDir(dir, hoster.Host())
if err != nil {
say.Verbose("Failed determine repository directory: %s", e)
Expand Down
23 changes: 11 additions & 12 deletions internal/gitclient/gitclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package gitclient
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"repo/internal/say"
"repo/internal/util"
"strconv"
Expand All @@ -24,7 +23,7 @@ func PrepareSsh(host string, sshUser string, sshPort int) {
}

func Clone(rootDir string, repoDir string, sshUrl string) error {
dirRepository := path.Join(rootDir, repoDir)
dirRepository := filepath.Join(rootDir, repoDir)
cmdGo := exec.Command("git", "clone", sshUrl, dirRepository)
if say.VerboseEnabled {
cmdGo.Stdout = os.Stdout
Expand Down Expand Up @@ -53,18 +52,18 @@ func GetLocalChanges(repoDir string) string {
}

func IsEmpty(repoDir string) bool {
fis, err := ioutil.ReadDir(path.Join(repoDir, ".git/objects"))
if err != nil {
gitDir := filepath.Join(repoDir, ".git")
if _, err := os.Stat(gitDir); os.IsNotExist(err) {
return true
}
for _, fi := range fis {
if !fi.IsDir() {
return true
}

refsHeads := filepath.Join(gitDir, "refs", "heads")
entries, err := os.ReadDir(refsHeads)
if err != nil {
return true
}
return false
//o, _, _ := util.RunCommandDir(&repoDir, "find", ".git/objects", "-type", "f")
//return len(o) == 0

return len(entries) == 0
}

func GetCurrentBranch(repoDir string) string {
Expand Down
4 changes: 2 additions & 2 deletions internal/model/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"repo/internal/say"
"repo/internal/util"
Expand All @@ -30,7 +30,7 @@ type RepoRemote struct {
}

func (rd RepoDir) RepoYamlFilename() string {
return path.Join(rd.Path, RepoYamlFilename)
return filepath.Join(rd.Path, RepoYamlFilename)
}

func (rd RepoDir) PathDirName() string {
Expand Down
Loading