@@ -10,6 +10,7 @@ import (
1010 "regexp"
1111 "strings"
1212
13+ "github.com/andornaut/gog/internal/git"
1314 "github.com/andornaut/gog/internal/repository"
1415)
1516
@@ -109,6 +110,7 @@ func File(repoPath, intPath string) error {
109110 if err == nil {
110111 // Success
111112 printLinked (intPath , extPath )
113+ addToGit (repoPath , intPath , extPath )
112114 return nil
113115 }
114116 if ! os .IsExist (err ) {
@@ -122,7 +124,7 @@ func File(repoPath, intPath string) error {
122124 return nil
123125 }
124126 if extFileInfo .IsDir () {
125- printError (intPath , fmt .Errorf ("path expected to be a file, but is a directory: %s" , extPath ))
127+ printError (intPath , fmt .Errorf ("path is expected to be a file, but is a directory: %s" , extPath ))
126128 return nil
127129 }
128130
@@ -139,6 +141,7 @@ func File(repoPath, intPath string) error {
139141
140142 if actualExtPath == intPath {
141143 // Already linked
144+ addToGit (repoPath , intPath , extPath )
142145 return nil
143146 }
144147
@@ -154,15 +157,21 @@ func File(repoPath, intPath string) error {
154157 return nil
155158 }
156159 }
157-
158160 if err = os .Symlink (intPath , extPath ); err != nil {
159161 printError (intPath , err )
160162 return nil
161163 }
162164 printLinked (intPath , extPath )
165+ addToGit (repoPath , intPath , extPath )
163166 return nil
164167}
165168
169+ func addToGit (repoPath , intPath , extPath string ) {
170+ if err := git .Run (repoPath , "add" , intPath ); err != nil {
171+ printError (intPath , err )
172+ }
173+ }
174+
166175func backup (p string ) bool {
167176 backupPath := backupPath (p )
168177 if err := os .Rename (p , backupPath ); err != nil {
0 commit comments