This repository has been archived on 2025-10-30. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
gitwarrior/cmd/pull.go

42 lines
1.2 KiB
Go

package cmd
import (
"fmt"
"os"
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/gitea"
"gitea.yves-biener.de/yves-biener/gitwarrior/internal/gitw"
"github.com/spf13/cobra"
)
func init() {
pullCmd.Flags().BoolVarP(&dry_run, "dry-run", "d", false, "Only output changes without applying them")
rootCmd.AddCommand(pullCmd)
}
var pullCmd = &cobra.Command{
Use: "pull",
Short: "Pull changes from git repository of current directory",
Long: `Pull changes of all issues and milestones from the git server identified by the remote url of the current working directory.
In case of merge conflicts $EDITOR is executed to manually edit the changes to resolve the merge conflicts directly.`,
Run: func(cmd *cobra.Command, args []string) {
server := gitea.NewGitea()
repository, err := gitw.Discover()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
repository, err = server.VerifyRepository(repository)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
project := gitw.NewProject(server, repository)
fmt.Printf("Pulling changes from %s\n", repository.Full_name)
if err = project.Pull(dry_run); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
},
}