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/push.go

41 lines
1.1 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() {
pushCmd.Flags().BoolVarP(&dry_run, "dry-run", "d", false, "Only output changes without applying them")
rootCmd.AddCommand(pushCmd)
}
var pushCmd = &cobra.Command{
Use: "push",
Short: "Push changes from taskwarrior to git repository of current directory",
Long: `Push changes for all taskwarrior tasks related to the repository to the git server identified by the remote url of the current working directory.`,
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("Push changes to %s\n", repository.Full_name)
if err = project.Push(dry_run); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(-1)
}
},
}