@@ -53,6 +53,11 @@ func Capture() (*Snapshot, error) {
5353 return nil , err
5454 }
5555
56+ dotfilesSnap , err := CaptureDotfiles ()
57+ if err != nil {
58+ return nil , err
59+ }
60+
5661 devTools , err := CaptureDevTools ()
5762 if err != nil {
5863 return nil , err
@@ -71,6 +76,7 @@ func Capture() (*Snapshot, error) {
7176 MacOSPrefs : prefs ,
7277 Shell : * shellSnap ,
7378 Git : * gitSnap ,
79+ Dotfiles : * dotfilesSnap ,
7480 DevTools : devTools ,
7581 MatchedPreset : "" ,
7682 CatalogMatch : CatalogMatch {
@@ -134,6 +140,12 @@ func CaptureWithProgress(callback func(step ScanStep)) (*Snapshot, error) {
134140 }},
135141 {"Shell Environment" , func () (interface {}, error ) { return CaptureShell () }, func (v interface {}) int { return 1 }},
136142 {"Git Configuration" , func () (interface {}, error ) { return CaptureGit () }, func (v interface {}) int { return 1 }},
143+ {"Dotfiles" , func () (interface {}, error ) { return CaptureDotfiles () }, func (v interface {}) int {
144+ if s , ok := v .(* DotfilesSnapshot ); ok && s .RepoURL != "" {
145+ return 1
146+ }
147+ return 0
148+ }},
137149 {"Dev Tools" , func () (interface {}, error ) { return CaptureDevTools () }, func (v interface {}) int {
138150 if s , ok := v .([]DevTool ); ok {
139151 return len (s )
@@ -169,7 +181,8 @@ func CaptureWithProgress(callback func(step ScanStep)) (*Snapshot, error) {
169181 prefs , _ := results [4 ].([]MacOSPref )
170182 shellSnap , _ := results [5 ].(* ShellSnapshot )
171183 gitSnap , _ := results [6 ].(* GitSnapshot )
172- devTools , _ := results [7 ].([]DevTool )
184+ dotfilesSnap , _ := results [7 ].(* DotfilesSnapshot )
185+ devTools , _ := results [8 ].([]DevTool )
173186
174187 if formulae == nil {
175188 formulae = []string {}
@@ -192,6 +205,9 @@ func CaptureWithProgress(callback func(step ScanStep)) (*Snapshot, error) {
192205 if gitSnap == nil {
193206 gitSnap = & GitSnapshot {}
194207 }
208+ if dotfilesSnap == nil {
209+ dotfilesSnap = & DotfilesSnapshot {}
210+ }
195211 if devTools == nil {
196212 devTools = []DevTool {}
197213 }
@@ -209,6 +225,7 @@ func CaptureWithProgress(callback func(step ScanStep)) (*Snapshot, error) {
209225 MacOSPrefs : prefs ,
210226 Shell : * shellSnap ,
211227 Git : * gitSnap ,
228+ Dotfiles : * dotfilesSnap ,
212229 DevTools : devTools ,
213230 MatchedPreset : "" ,
214231 CatalogMatch : CatalogMatch {
@@ -403,6 +420,27 @@ func CaptureDevTools() ([]DevTool, error) {
403420 return tools , nil
404421}
405422
423+ func CaptureDotfiles () (* DotfilesSnapshot , error ) {
424+ home , err := os .UserHomeDir ()
425+ if err != nil {
426+ return & DotfilesSnapshot {}, nil
427+ }
428+
429+ dotfilesPath := filepath .Join (home , ".dotfiles" )
430+ if _ , err := os .Stat (filepath .Join (dotfilesPath , ".git" )); err != nil {
431+ return & DotfilesSnapshot {}, nil
432+ }
433+
434+ out , err := exec .Command ("git" , "-C" , dotfilesPath , "remote" , "get-url" , "origin" ).Output ()
435+ if err != nil {
436+ return & DotfilesSnapshot {}, nil
437+ }
438+
439+ return & DotfilesSnapshot {
440+ RepoURL : strings .TrimSpace (string (out )),
441+ }, nil
442+ }
443+
406444func sanitizePath (path string ) string {
407445 home , err := os .UserHomeDir ()
408446 if err != nil {
0 commit comments