Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

bug(dtgithub): cloneRepo expands the literal string "projectPath" as its target directory and reports success without cloning

Aperta
#262 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
git, github, go
Ambito
cli

Direzione di ricerca

Start in pkg/dtgithub/github_repo_projects_store.go, reading projectCreator.cloneRepo and its CreateProject caller. Compare the intended local path with the path computed by addProjectToDataTugConfig, then confirm the desired clone-or-error behavior with the maintainer. Done means CreateProject no longer reports a successful clone when no clone occurred.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

projectCreator.cloneRepo resolves its local directory from the literal string "projectPath", not from any project path, and then clones nothing anyway. It returns nil regardless, so CreateProject reports the clone as successful.

Trigger

pkg/dtgithub/github_repo_projects_store.go:

func (c *projectCreator) cloneRepo() (err error) {
	localDir := fsutils.ExpandHome("projectPath")
	dirExists, _ := fsutils.DirExists(localDir)
	if !dirExists {
		parent := filepath.Dir(localDir)
		_ = os.MkdirAll(parent, 0o755)
		cloneUrl := c.repo.GetCloneURL()
		if cloneUrl == "" {
			cloneUrl = fmt.Sprintf("https://github.com/%s/%s.git", c.repoOwner, c.repoName)
			_ = cloneUrl
		}
		//_, err = git.PlainClone(localDir, false, &git.CloneOptions{
		//	...
	}
	return nil
}

"projectPath" has no ~ prefix, so ExpandHome returns it unchanged and the path is resolved relative to the process's working directory. The git.PlainClone call that would use it is commented out, and cloneUrl is computed and then discarded into _. The net effect is an os.MkdirAll on the current directory and nothing else.

CreateProject calls this between creating the repo and writing the project files, and treats the nil as "cloned":

if err = c.cloneRepo(); err != nil {
	return fmt.Errorf("failed to clone GitHub repository '%s/%s': %w", c.repoOwner, c.repoName, err)
}

Expected

Either clone into the project's real local directory (~/datatug/github.com/{owner}/{repo}, as addProjectToDataTugConfig already computes), or return a "not implemented" error so the caller does not report success for work that never happened. A placeholder string should not be silently treated as a path.

Notes

Found while adapting the CLI to datatug-core v0.39.0's caller-supplied project id (#259); deliberately not fixed there, since finishing the clone is a feature decision rather than part of the id change. Third of three pre-existing defects on this code path — see the sibling issues on the panicking projectID split and on projectCreator's unset fields.

Lingua principale
Go
Stelle
1
Fork
0
Merge medio
1h 50m
PR unite (30g)
119

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di datatug/datatug-cli

Tutte le issue di datatug/datatug-cli

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.