mirror of
https://github.com/yarlson/lnk.git
synced 2025-08-31 18:01:41 +02:00
feat: implement phase 1 sync functionality
- Add lnk status command to show repository sync status - Add lnk push command for smart staging, committing, and pushing - Add lnk pull command with automatic symlink restoration - Add comprehensive sync functionality to git and core packages - Add 5 new integration tests for sync commands (17 total tests) - Update README with sync workflow examples and documentation - Support commits ahead/behind tracking relative to remote - Implement change detection to avoid empty commits - Add graceful error handling for missing remotes Closes: Phase 1 sync implementation
This commit is contained in:
36
cmd/pull.go
Normal file
36
cmd/pull.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/yarlson/lnk/internal/core"
|
||||
)
|
||||
|
||||
var pullCmd = &cobra.Command{
|
||||
Use: "pull",
|
||||
Short: "Pull changes from remote and restore symlinks",
|
||||
Long: "Fetches changes from remote repository and automatically restores symlinks for all managed files.",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
lnk := core.NewLnk()
|
||||
restored, err := lnk.Pull()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to pull changes: %w", err)
|
||||
}
|
||||
|
||||
if len(restored) > 0 {
|
||||
fmt.Printf("Successfully pulled changes and restored %d symlink(s):\n", len(restored))
|
||||
for _, file := range restored {
|
||||
fmt.Printf(" - %s\n", file)
|
||||
}
|
||||
} else {
|
||||
fmt.Println("Successfully pulled changes (no symlinks needed restoration)")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(pullCmd)
|
||||
}
|
Reference in New Issue
Block a user