Skip to content

status not able to track any comitted file #1140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Manik2708 opened this issue Jul 13, 2024 · 2 comments
Closed

status not able to track any comitted file #1140

Manik2708 opened this issue Jul 13, 2024 · 2 comments

Comments

@Manik2708
Copy link

Manik2708 commented Jul 13, 2024

Please see this function:

func run() error {
      // Please see that this is just an example for checking status of a file, hence it has hard-coded strings 
	r, err := git.PlainOpenWithOptions("../bsf-ci", &git.PlainOpenOptions{DetectDotGit: true})
	if err != nil {
		return err
	}
	// Get the working tree
	w, err := r.Worktree()
	if err != nil {
		return err
	}
	status, err:= w.Status()
	if err!=nil{
		return err
	}
	fl:= status.File("go.mod")
	println(fl.Staging) // Always printing 63 that means untracked
	println(status.IsUntracked("go.mod")) // always giving false
	fmt.Printf("Staging: %c\n", fl.Staging)
	return nil
}

The problem is that it is always giving 63/? for go.mod. But once .git or .github are removed and repository is re-initiated, it starts tracking the file.

The error is, go git is returning file as untracked, if it is committed

The bsf-ci repository is: https://github.com/Manik2708/bsf-ci/
The original bsf repository: https://github.com/buildsafedev/bsf

@Manik2708 Manik2708 changed the title status not able to track any file status not able to track any comitted file Jul 13, 2024
@pjbgf
Copy link
Member

pjbgf commented Aug 4, 2024

@Manik2708 I believe this was fixed by #1023. Please try it again using the latest version within master using the newly added StatusWithOptions:

status, err := w.StatusWithOptions(StatusOptions{Strategy: Preload})

@Manik2708
Copy link
Author

Manik2708 commented Aug 4, 2024

Thanks @pjbgf, I think we can close this then!

@pjbgf pjbgf closed this as completed Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants