Merge branch 'master' into config-next-remove-legacy
This commit is contained in:
commit
44cd61ae04
@ -11,7 +11,7 @@ Git LFS. If you have an idea for a new feature, open an issue for discussion.
|
|||||||
| :soon: | `authenticated` property on urls | [#960](https://github.com/github/git-lfs/issues/960) |
|
| :soon: | `authenticated` property on urls | [#960](https://github.com/github/git-lfs/issues/960) |
|
||||||
| :soon: | Add ref information to upload request | [#969](https://github.com/github/git-lfs/issues/969) |
|
| :soon: | Add ref information to upload request | [#969](https://github.com/github/git-lfs/issues/969) |
|
||||||
| :soon: | Accept raw remote URLs as valid | [#1085](https://github.com/github/git-lfs/issues/1085) |
|
| :soon: | Accept raw remote URLs as valid | [#1085](https://github.com/github/git-lfs/issues/1085) |
|
||||||
| :construction: | `config` refactoring | |
|
| :construction: | `config` refactoring | [#1425](https://github.com/github/git-lfs/issues/1425) |
|
||||||
| :soon: | Socks proxy support | [#1424](https://github.com/github/git-lfs/issues/1424) |
|
| :soon: | Socks proxy support | [#1424](https://github.com/github/git-lfs/issues/1424) |
|
||||||
| :no_entry_sign: | Not following 301 redirect | [#1129](https://github.com/github/git-lfs/issues/1129) |
|
| :no_entry_sign: | Not following 301 redirect | [#1129](https://github.com/github/git-lfs/issues/1129) |
|
||||||
| | add all lfs.\* git config keys to git lfs env output | |
|
| | add all lfs.\* git config keys to git lfs env output | |
|
||||||
|
@ -11,18 +11,10 @@ import (
|
|||||||
"github.com/github/git-lfs/git"
|
"github.com/github/git-lfs/git"
|
||||||
"github.com/github/git-lfs/lfs"
|
"github.com/github/git-lfs/lfs"
|
||||||
"github.com/github/git-lfs/progress"
|
"github.com/github/git-lfs/progress"
|
||||||
"github.com/github/git-lfs/transfer"
|
|
||||||
"github.com/rubyist/tracerx"
|
"github.com/rubyist/tracerx"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
checkoutCmd = &cobra.Command{
|
|
||||||
Use: "checkout",
|
|
||||||
Run: checkoutCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func checkoutCommand(cmd *cobra.Command, args []string) {
|
func checkoutCommand(cmd *cobra.Command, args []string) {
|
||||||
requireInRepo()
|
requireInRepo()
|
||||||
|
|
||||||
@ -43,10 +35,6 @@ func checkoutCommand(cmd *cobra.Command, args []string) {
|
|||||||
checkoutWithIncludeExclude(rootedpaths, nil)
|
checkoutWithIncludeExclude(rootedpaths, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
RootCmd.AddCommand(checkoutCmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checkout from items reported from the fetch process (in parallel)
|
// Checkout from items reported from the fetch process (in parallel)
|
||||||
func checkoutAllFromFetchChan(c chan *lfs.WrappedPointer) {
|
func checkoutAllFromFetchChan(c chan *lfs.WrappedPointer) {
|
||||||
tracerx.Printf("starting fetch/parallel checkout")
|
tracerx.Printf("starting fetch/parallel checkout")
|
||||||
@ -179,7 +167,7 @@ func checkoutWithChan(in <-chan *lfs.WrappedPointer) {
|
|||||||
|
|
||||||
// As files come in, write them to the wd and update the index
|
// As files come in, write them to the wd and update the index
|
||||||
|
|
||||||
manifest := transfer.ConfigureManifest(transfer.NewManifest(), cfg)
|
manifest := TransferManifest()
|
||||||
|
|
||||||
for pointer := range in {
|
for pointer := range in {
|
||||||
|
|
||||||
@ -241,3 +229,12 @@ func checkoutWithChan(in <-chan *lfs.WrappedPointer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: "checkout",
|
||||||
|
Run: checkoutCommand,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -9,13 +9,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
cleanCmd = &cobra.Command{
|
|
||||||
Use: "clean",
|
|
||||||
Run: cleanCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func cleanCommand(cmd *cobra.Command, args []string) {
|
func cleanCommand(cmd *cobra.Command, args []string) {
|
||||||
requireStdin("This command should be run by the Git 'clean' filter")
|
requireStdin("This command should be run by the Git 'clean' filter")
|
||||||
lfs.InstallHooks(false)
|
lfs.InstallHooks(false)
|
||||||
@ -82,5 +75,10 @@ func cleanCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(cleanCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: "clean",
|
||||||
|
Run: cleanCommand,
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
cloneCmd = &cobra.Command{
|
|
||||||
Use: "clone",
|
|
||||||
Run: cloneCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
cloneFlags git.CloneFlags
|
cloneFlags git.CloneFlags
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -112,34 +107,40 @@ func postCloneSubmodules(args []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// Mirror all git clone flags
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.TemplateDirectory, "template", "", "", "See 'git clone --help'")
|
cmd := &cobra.Command{
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Local, "local", "l", false, "See 'git clone --help'")
|
Use: "clone",
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Shared, "shared", "s", false, "See 'git clone --help'")
|
Run: cloneCommand,
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.NoHardlinks, "no-hardlinks", "", false, "See 'git clone --help'")
|
}
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Quiet, "quiet", "q", false, "See 'git clone --help'")
|
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.NoCheckout, "no-checkout", "n", false, "See 'git clone --help'")
|
// Mirror all git clone flags
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Progress, "progress", "", false, "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.TemplateDirectory, "template", "", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Bare, "bare", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Local, "local", "l", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Mirror, "mirror", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Shared, "shared", "s", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Origin, "origin", "o", "", "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.NoHardlinks, "no-hardlinks", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Branch, "branch", "b", "", "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Quiet, "quiet", "q", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Upload, "upload-pack", "u", "", "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.NoCheckout, "no-checkout", "n", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Reference, "reference", "", "", "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Progress, "progress", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Dissociate, "dissociate", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Bare, "bare", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.SeparateGit, "separate-git-dir", "", "", "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Mirror, "mirror", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Depth, "depth", "", "", "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.Origin, "origin", "o", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Recursive, "recursive", "", false, "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.Branch, "branch", "b", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.RecurseSubmodules, "recurse-submodules", "", false, "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.Upload, "upload-pack", "u", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&cloneFlags.Config, "config", "c", "", "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.Reference, "reference", "", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.SingleBranch, "single-branch", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Dissociate, "dissociate", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.NoSingleBranch, "no-single-branch", "", false, "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.SeparateGit, "separate-git-dir", "", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Verbose, "verbose", "", false, "See 'git clone --help'")
|
cmd.Flags().StringVarP(&cloneFlags.Depth, "depth", "", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Ipv4, "ipv4", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.Recursive, "recursive", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().BoolVarP(&cloneFlags.Ipv6, "ipv6", "", false, "See 'git clone --help'")
|
cmd.Flags().BoolVarP(&cloneFlags.RecurseSubmodules, "recurse-submodules", "", false, "See 'git clone --help'")
|
||||||
|
cmd.Flags().StringVarP(&cloneFlags.Config, "config", "c", "", "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
cmd.Flags().BoolVarP(&cloneFlags.SingleBranch, "single-branch", "", false, "See 'git clone --help'")
|
||||||
cloneCmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
cmd.Flags().BoolVarP(&cloneFlags.NoSingleBranch, "no-single-branch", "", false, "See 'git clone --help'")
|
||||||
|
cmd.Flags().BoolVarP(&cloneFlags.Verbose, "verbose", "", false, "See 'git clone --help'")
|
||||||
RootCmd.AddCommand(cloneCmd)
|
cmd.Flags().BoolVarP(&cloneFlags.Ipv4, "ipv4", "", false, "See 'git clone --help'")
|
||||||
|
cmd.Flags().BoolVarP(&cloneFlags.Ipv6, "ipv6", "", false, "See 'git clone --help'")
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
||||||
|
cmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
envCmd = &cobra.Command{
|
|
||||||
Use: "env",
|
|
||||||
Run: envCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func envCommand(cmd *cobra.Command, args []string) {
|
func envCommand(cmd *cobra.Command, args []string) {
|
||||||
config.ShowConfigWarnings = true
|
config.ShowConfigWarnings = true
|
||||||
endpoint := cfg.Endpoint("download")
|
endpoint := cfg.Endpoint("download")
|
||||||
@ -42,7 +35,7 @@ func envCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, env := range lfs.Environ() {
|
for _, env := range lfs.Environ(cfg, TransferManifest()) {
|
||||||
Print(env)
|
Print(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,5 +46,10 @@ func envCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(envCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: "env",
|
||||||
|
Run: envCommand,
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,19 +7,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
extCmd = &cobra.Command{
|
|
||||||
Use: "ext",
|
|
||||||
Run: extCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
extListCmd = &cobra.Command{
|
|
||||||
Use: "list",
|
|
||||||
Short: "View details for specified extensions",
|
|
||||||
Run: extListCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func extCommand(cmd *cobra.Command, args []string) {
|
func extCommand(cmd *cobra.Command, args []string) {
|
||||||
printAllExts()
|
printAllExts()
|
||||||
}
|
}
|
||||||
@ -56,6 +43,17 @@ func printExt(ext config.Extension) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
extCmd.AddCommand(extListCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(extCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "ext",
|
||||||
|
Run: extCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(&cobra.Command{
|
||||||
|
Use: "list",
|
||||||
|
Short: "View details for specified extensions",
|
||||||
|
Run: extListCommand,
|
||||||
|
})
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
fetchCmd = &cobra.Command{
|
|
||||||
Use: "fetch",
|
|
||||||
Run: fetchCommand,
|
|
||||||
}
|
|
||||||
fetchRecentArg bool
|
fetchRecentArg bool
|
||||||
fetchAllArg bool
|
fetchAllArg bool
|
||||||
fetchPruneArg bool
|
fetchPruneArg bool
|
||||||
@ -111,15 +107,6 @@ func fetchCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
fetchCmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
|
||||||
fetchCmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
|
||||||
fetchCmd.Flags().BoolVarP(&fetchRecentArg, "recent", "r", false, "Fetch recent refs & commits")
|
|
||||||
fetchCmd.Flags().BoolVarP(&fetchAllArg, "all", "a", false, "Fetch all LFS files ever referenced")
|
|
||||||
fetchCmd.Flags().BoolVarP(&fetchPruneArg, "prune", "p", false, "After fetching, prune old data")
|
|
||||||
RootCmd.AddCommand(fetchCmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func pointersToFetchForRef(ref string) ([]*lfs.WrappedPointer, error) {
|
func pointersToFetchForRef(ref string) ([]*lfs.WrappedPointer, error) {
|
||||||
// Use SkipDeletedBlobs to avoid fetching ALL previous versions of modified files
|
// Use SkipDeletedBlobs to avoid fetching ALL previous versions of modified files
|
||||||
opts := lfs.NewScanRefsOptions()
|
opts := lfs.NewScanRefsOptions()
|
||||||
@ -330,3 +317,19 @@ func fetchAndReportToChan(pointers []*lfs.WrappedPointer, include, exclude []str
|
|||||||
}
|
}
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "fetch",
|
||||||
|
Run: fetchCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
||||||
|
cmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
||||||
|
cmd.Flags().BoolVarP(&fetchRecentArg, "recent", "r", false, "Fetch recent refs & commits")
|
||||||
|
cmd.Flags().BoolVarP(&fetchAllArg, "all", "a", false, "Fetch all LFS files ever referenced")
|
||||||
|
cmd.Flags().BoolVarP(&fetchPruneArg, "prune", "p", false, "After fetching, prune old data")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -15,11 +15,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
fsckDryRun bool
|
fsckDryRun bool
|
||||||
|
|
||||||
fsckCmd = &cobra.Command{
|
|
||||||
Use: "fsck",
|
|
||||||
Run: fsckCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func doFsck() (bool, error) {
|
func doFsck() (bool, error) {
|
||||||
@ -120,6 +115,13 @@ func fsckCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
fsckCmd.Flags().BoolVarP(&fsckDryRun, "dry-run", "d", false, "List corrupt objects without deleting them.")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(fsckCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "fsck",
|
||||||
|
Run: fsckCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&fsckDryRun, "dry-run", "d", false, "List corrupt objects without deleting them.")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,19 +8,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Remove for Git LFS v2.0 https://github.com/github/git-lfs/issues/839
|
// TODO: Remove for Git LFS v2.0 https://github.com/github/git-lfs/issues/839
|
||||||
|
|
||||||
var (
|
|
||||||
initCmd = &cobra.Command{
|
|
||||||
Use: "init",
|
|
||||||
Run: initCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
initHooksCmd = &cobra.Command{
|
|
||||||
Use: "hooks",
|
|
||||||
Run: initHooksCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func initCommand(cmd *cobra.Command, args []string) {
|
func initCommand(cmd *cobra.Command, args []string) {
|
||||||
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs init' is deprecated. Use 'git lfs install' now.\n")
|
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs init' is deprecated. Use 'git lfs install' now.\n")
|
||||||
installCommand(cmd, args)
|
installCommand(cmd, args)
|
||||||
@ -32,9 +19,19 @@ func initHooksCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
initCmd.Flags().BoolVarP(&forceInstall, "force", "f", false, "Set the Git LFS global config, overwriting previous values.")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
initCmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Set the Git LFS config for the local Git repository only.")
|
cmd := &cobra.Command{
|
||||||
initCmd.Flags().BoolVarP(&skipSmudgeInstall, "skip-smudge", "s", false, "Skip automatic downloading of objects on clone or pull.")
|
Use: "init",
|
||||||
initCmd.AddCommand(initHooksCmd)
|
Run: initCommand,
|
||||||
RootCmd.AddCommand(initCmd)
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&forceInstall, "force", "f", false, "Set the Git LFS global config, overwriting previous values.")
|
||||||
|
cmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Set the Git LFS config for the local Git repository only.")
|
||||||
|
cmd.Flags().BoolVarP(&skipSmudgeInstall, "skip-smudge", "s", false, "Skip automatic downloading of objects on clone or pull.")
|
||||||
|
cmd.AddCommand(&cobra.Command{
|
||||||
|
Use: "hooks",
|
||||||
|
Run: initHooksCommand,
|
||||||
|
})
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,16 +6,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
installCmd = &cobra.Command{
|
|
||||||
Use: "install",
|
|
||||||
Run: installCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
installHooksCmd = &cobra.Command{
|
|
||||||
Use: "hooks",
|
|
||||||
Run: installHooksCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
forceInstall = false
|
forceInstall = false
|
||||||
localInstall = false
|
localInstall = false
|
||||||
skipSmudgeInstall = false
|
skipSmudgeInstall = false
|
||||||
@ -50,9 +40,19 @@ func installHooksCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
installCmd.Flags().BoolVarP(&forceInstall, "force", "f", false, "Set the Git LFS global config, overwriting previous values.")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
installCmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Set the Git LFS config for the local Git repository only.")
|
cmd := &cobra.Command{
|
||||||
installCmd.Flags().BoolVarP(&skipSmudgeInstall, "skip-smudge", "s", false, "Skip automatic downloading of objects on clone or pull.")
|
Use: "install",
|
||||||
installCmd.AddCommand(installHooksCmd)
|
Run: installCommand,
|
||||||
RootCmd.AddCommand(installCmd)
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&forceInstall, "force", "f", false, "Set the Git LFS global config, overwriting previous values.")
|
||||||
|
cmd.Flags().BoolVarP(&localInstall, "local", "l", false, "Set the Git LFS config for the local Git repository only.")
|
||||||
|
cmd.Flags().BoolVarP(&skipSmudgeInstall, "skip-smudge", "s", false, "Skip automatic downloading of objects on clone or pull.")
|
||||||
|
cmd.AddCommand(&cobra.Command{
|
||||||
|
Use: "hooks",
|
||||||
|
Run: installHooksCommand,
|
||||||
|
})
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,6 @@ var (
|
|||||||
setLockRemoteFor = func(c *config.Configuration) {
|
setLockRemoteFor = func(c *config.Configuration) {
|
||||||
c.CurrentRemote = lockRemote
|
c.CurrentRemote = lockRemote
|
||||||
}
|
}
|
||||||
|
|
||||||
lockCmd = &cobra.Command{
|
|
||||||
Use: "lock",
|
|
||||||
Run: lockCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func lockCommand(cmd *cobra.Command, args []string) {
|
func lockCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -107,9 +102,17 @@ func lockPath(file string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
lockCmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
if !isCommandEnabled(cfg, "locks") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if isCommandEnabled(cfg, "locks") {
|
cmd := &cobra.Command{
|
||||||
RootCmd.AddCommand(lockCmd)
|
Use: "lock",
|
||||||
|
Run: lockCommand,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
locksCmdFlags = new(locksFlags)
|
locksCmdFlags = new(locksFlags)
|
||||||
locksCmd = &cobra.Command{
|
|
||||||
Use: "locks",
|
|
||||||
Run: locksCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func locksCommand(cmd *cobra.Command, args []string) {
|
func locksCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -55,18 +51,6 @@ func locksCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
locksCmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
|
||||||
|
|
||||||
locksCmd.Flags().StringVarP(&locksCmdFlags.Path, "path", "p", "", "filter locks results matching a particular path")
|
|
||||||
locksCmd.Flags().StringVarP(&locksCmdFlags.Id, "id", "i", "", "filter locks results matching a particular ID")
|
|
||||||
locksCmd.Flags().IntVarP(&locksCmdFlags.Limit, "limit", "l", 0, "optional limit for number of results to return")
|
|
||||||
|
|
||||||
if isCommandEnabled(cfg, "locks") {
|
|
||||||
RootCmd.AddCommand(locksCmd)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// locksFlags wraps up and holds all of the flags that can be given to the
|
// locksFlags wraps up and holds all of the flags that can be given to the
|
||||||
// `git lfs locks` command.
|
// `git lfs locks` command.
|
||||||
type locksFlags struct {
|
type locksFlags struct {
|
||||||
@ -101,3 +85,21 @@ func (l *locksFlags) Filters() ([]api.Filter, error) {
|
|||||||
|
|
||||||
return filters, nil
|
return filters, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
if !isCommandEnabled(cfg, "locks") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "locks",
|
||||||
|
Run: locksCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
||||||
|
cmd.Flags().StringVarP(&locksCmdFlags.Path, "path", "p", "", "filter locks results matching a particular path")
|
||||||
|
cmd.Flags().StringVarP(&locksCmdFlags.Id, "id", "i", "", "filter locks results matching a particular ID")
|
||||||
|
cmd.Flags().IntVarP(&locksCmdFlags.Limit, "limit", "l", 0, "optional limit for number of results to return")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -11,33 +11,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
logsCmd = &cobra.Command{
|
|
||||||
Use: "logs",
|
|
||||||
Run: logsCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
logsLastCmd = &cobra.Command{
|
|
||||||
Use: "last",
|
|
||||||
Run: logsLastCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
logsShowCmd = &cobra.Command{
|
|
||||||
Use: "show",
|
|
||||||
Run: logsShowCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
logsClearCmd = &cobra.Command{
|
|
||||||
Use: "clear",
|
|
||||||
Run: logsClearCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
logsBoomtownCmd = &cobra.Command{
|
|
||||||
Use: "boomtown",
|
|
||||||
Run: logsBoomtownCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func logsCommand(cmd *cobra.Command, args []string) {
|
func logsCommand(cmd *cobra.Command, args []string) {
|
||||||
for _, path := range sortedLogs() {
|
for _, path := range sortedLogs() {
|
||||||
Print(path)
|
Print(path)
|
||||||
@ -104,6 +77,30 @@ func sortedLogs() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
logsCmd.AddCommand(logsLastCmd, logsShowCmd, logsClearCmd, logsBoomtownCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(logsCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "logs",
|
||||||
|
Run: logsCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(
|
||||||
|
&cobra.Command{
|
||||||
|
Use: "last",
|
||||||
|
Run: logsLastCommand,
|
||||||
|
},
|
||||||
|
&cobra.Command{
|
||||||
|
Use: "show",
|
||||||
|
Run: logsShowCommand,
|
||||||
|
},
|
||||||
|
&cobra.Command{
|
||||||
|
Use: "clear",
|
||||||
|
Run: logsClearCommand,
|
||||||
|
},
|
||||||
|
&cobra.Command{
|
||||||
|
Use: "boomtown",
|
||||||
|
Run: logsBoomtownCommand,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
longOIDs = false
|
longOIDs = false
|
||||||
lsFilesCmd = &cobra.Command{
|
|
||||||
Use: "ls-files",
|
|
||||||
Run: lsFilesCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func lsFilesCommand(cmd *cobra.Command, args []string) {
|
func lsFilesCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -57,6 +53,13 @@ func lsFilesMarker(p *lfs.WrappedPointer) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
lsFilesCmd.Flags().BoolVarP(&longOIDs, "long", "l", false, "")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(lsFilesCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "ls-files",
|
||||||
|
Run: lsFilesCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&longOIDs, "long", "l", false, "")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,6 @@ var (
|
|||||||
pointerFile string
|
pointerFile string
|
||||||
pointerCompare string
|
pointerCompare string
|
||||||
pointerStdin bool
|
pointerStdin bool
|
||||||
pointerCmd = &cobra.Command{
|
|
||||||
Use: "pointer",
|
|
||||||
Run: pointerCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func pointerCommand(cmd *cobra.Command, args []string) {
|
func pointerCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -133,9 +129,15 @@ func gitHashObject(by []byte) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flags := pointerCmd.Flags()
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
flags.StringVarP(&pointerFile, "file", "f", "", "Path to a local file to generate the pointer from.")
|
cmd := &cobra.Command{
|
||||||
flags.StringVarP(&pointerCompare, "pointer", "p", "", "Path to a local file containing a pointer built by another Git LFS implementation.")
|
Use: "pointer",
|
||||||
flags.BoolVarP(&pointerStdin, "stdin", "", false, "Read a pointer built by another Git LFS implementation through STDIN.")
|
Run: pointerCommand,
|
||||||
RootCmd.AddCommand(pointerCmd)
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&pointerFile, "file", "f", "", "Path to a local file to generate the pointer from.")
|
||||||
|
cmd.Flags().StringVarP(&pointerCompare, "pointer", "p", "", "Path to a local file containing a pointer built by another Git LFS implementation.")
|
||||||
|
cmd.Flags().BoolVarP(&pointerStdin, "stdin", "", false, "Read a pointer built by another Git LFS implementation through STDIN.")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
prePushCmd = &cobra.Command{
|
|
||||||
Use: "pre-push",
|
|
||||||
Run: prePushCommand,
|
|
||||||
}
|
|
||||||
prePushDryRun = false
|
prePushDryRun = false
|
||||||
prePushDeleteBranch = strings.Repeat("0", 40)
|
prePushDeleteBranch = strings.Repeat("0", 40)
|
||||||
)
|
)
|
||||||
@ -100,6 +96,13 @@ func decodeRefs(input string) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
prePushCmd.Flags().BoolVarP(&prePushDryRun, "dry-run", "d", false, "Do everything except actually send the updates")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(prePushCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "pre-push",
|
||||||
|
Run: prePushCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&prePushDryRun, "dry-run", "d", false, "Do everything except actually send the updates")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pruneCmd = &cobra.Command{
|
|
||||||
Use: "prune",
|
|
||||||
Short: "Deletes old LFS files from the local store",
|
|
||||||
Run: pruneCommand,
|
|
||||||
}
|
|
||||||
pruneDryRunArg bool
|
pruneDryRunArg bool
|
||||||
pruneVerboseArg bool
|
pruneVerboseArg bool
|
||||||
pruneVerifyArg bool
|
pruneVerifyArg bool
|
||||||
@ -479,9 +474,17 @@ func pruneTaskGetReachableObjects(outObjectSet *tools.StringSet, errorChan chan
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pruneCmd.Flags().BoolVarP(&pruneDryRunArg, "dry-run", "d", false, "Don't delete anything, just report")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
pruneCmd.Flags().BoolVarP(&pruneVerboseArg, "verbose", "v", false, "Print full details of what is/would be deleted")
|
cmd := &cobra.Command{
|
||||||
pruneCmd.Flags().BoolVarP(&pruneVerifyArg, "verify-remote", "c", false, "Verify that remote has LFS files before deleting")
|
Use: "prune",
|
||||||
pruneCmd.Flags().BoolVar(&pruneDoNotVerifyArg, "no-verify-remote", false, "Override lfs.pruneverifyremotealways and don't verify")
|
Short: "Deletes old LFS files from the local store",
|
||||||
RootCmd.AddCommand(pruneCmd)
|
Run: pruneCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&pruneDryRunArg, "dry-run", "d", false, "Don't delete anything, just report")
|
||||||
|
cmd.Flags().BoolVarP(&pruneVerboseArg, "verbose", "v", false, "Print full details of what is/would be deleted")
|
||||||
|
cmd.Flags().BoolVarP(&pruneVerifyArg, "verify-remote", "c", false, "Verify that remote has LFS files before deleting")
|
||||||
|
cmd.Flags().BoolVar(&pruneDoNotVerifyArg, "no-verify-remote", false, "Override lfs.pruneverifyremotealways and don't verify")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
pullCmd = &cobra.Command{
|
|
||||||
Use: "pull",
|
|
||||||
Run: pullCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func pullCommand(cmd *cobra.Command, args []string) {
|
func pullCommand(cmd *cobra.Command, args []string) {
|
||||||
requireInRepo()
|
requireInRepo()
|
||||||
|
|
||||||
@ -50,7 +43,14 @@ func pull(includePaths, excludePaths []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pullCmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
pullCmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
cmd := &cobra.Command{
|
||||||
RootCmd.AddCommand(pullCmd)
|
Use: "pull",
|
||||||
|
Run: pullCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&includeArg, "include", "I", "", "Include a list of paths")
|
||||||
|
cmd.Flags().StringVarP(&excludeArg, "exclude", "X", "", "Exclude a list of paths")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pushCmd = &cobra.Command{
|
|
||||||
Use: "push",
|
|
||||||
Run: pushCommand,
|
|
||||||
}
|
|
||||||
pushDryRun = false
|
pushDryRun = false
|
||||||
pushObjectIDs = false
|
pushObjectIDs = false
|
||||||
pushAll = false
|
pushAll = false
|
||||||
@ -165,10 +161,16 @@ func pushCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
pushCmd.Flags().BoolVarP(&pushDryRun, "dry-run", "d", false, "Do everything except actually send the updates")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
pushCmd.Flags().BoolVarP(&useStdin, "stdin", "s", false, "Take refs on stdin (for pre-push hook)")
|
cmd := &cobra.Command{
|
||||||
pushCmd.Flags().BoolVarP(&pushObjectIDs, "object-id", "o", false, "Push LFS object ID(s)")
|
Use: "push",
|
||||||
pushCmd.Flags().BoolVarP(&pushAll, "all", "a", false, "Push all objects for the current ref to the remote.")
|
Run: pushCommand,
|
||||||
|
}
|
||||||
RootCmd.AddCommand(pushCmd)
|
|
||||||
|
cmd.Flags().BoolVarP(&pushDryRun, "dry-run", "d", false, "Do everything except actually send the updates")
|
||||||
|
cmd.Flags().BoolVarP(&useStdin, "stdin", "s", false, "Take refs on stdin (for pre-push hook)")
|
||||||
|
cmd.Flags().BoolVarP(&pushObjectIDs, "object-id", "o", false, "Push LFS object ID(s)")
|
||||||
|
cmd.Flags().BoolVarP(&pushAll, "all", "a", false, "Push all objects for the current ref to the remote.")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,17 +8,12 @@ import (
|
|||||||
|
|
||||||
"github.com/github/git-lfs/errutil"
|
"github.com/github/git-lfs/errutil"
|
||||||
"github.com/github/git-lfs/lfs"
|
"github.com/github/git-lfs/lfs"
|
||||||
"github.com/github/git-lfs/transfer"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
smudgeInfo = false
|
smudgeInfo = false
|
||||||
smudgeSkip = false
|
smudgeSkip = false
|
||||||
smudgeCmd = &cobra.Command{
|
|
||||||
Use: "smudge",
|
|
||||||
Run: smudgeCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func smudgeCommand(cmd *cobra.Command, args []string) {
|
func smudgeCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -68,8 +63,7 @@ func smudgeCommand(cmd *cobra.Command, args []string) {
|
|||||||
download = false
|
download = false
|
||||||
}
|
}
|
||||||
|
|
||||||
manifest := transfer.ConfigureManifest(transfer.NewManifest(), cfg)
|
err = ptr.Smudge(os.Stdout, filename, download, TransferManifest(), cb)
|
||||||
err = ptr.Smudge(os.Stdout, filename, download, manifest, cb)
|
|
||||||
if file != nil {
|
if file != nil {
|
||||||
file.Close()
|
file.Close()
|
||||||
}
|
}
|
||||||
@ -99,8 +93,14 @@ func smudgeFilename(args []string, err error) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// update man page
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
smudgeCmd.Flags().BoolVarP(&smudgeInfo, "info", "i", false, "")
|
cmd := &cobra.Command{
|
||||||
smudgeCmd.Flags().BoolVarP(&smudgeSkip, "skip", "s", false, "")
|
Use: "smudge",
|
||||||
RootCmd.AddCommand(smudgeCmd)
|
Run: smudgeCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&smudgeInfo, "info", "i", false, "")
|
||||||
|
cmd.Flags().BoolVarP(&smudgeSkip, "skip", "s", false, "")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
statusCmd = &cobra.Command{
|
|
||||||
Use: "status",
|
|
||||||
Run: statusCommand,
|
|
||||||
}
|
|
||||||
porcelain = false
|
porcelain = false
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -101,6 +97,13 @@ func humanizeBytes(bytes int64) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
statusCmd.Flags().BoolVarP(&porcelain, "porcelain", "p", false, "Give the output in an easy-to-parse format for scripts.")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(statusCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "status",
|
||||||
|
Run: statusCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&porcelain, "porcelain", "p", false, "Give the output in an easy-to-parse format for scripts.")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,6 @@ var (
|
|||||||
".git", ".lfs",
|
".git", ".lfs",
|
||||||
}
|
}
|
||||||
|
|
||||||
trackCmd = &cobra.Command{
|
|
||||||
Use: "track",
|
|
||||||
Run: trackCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
trackVerboseLoggingFlag bool
|
trackVerboseLoggingFlag bool
|
||||||
trackDryRunFlag bool
|
trackDryRunFlag bool
|
||||||
)
|
)
|
||||||
@ -234,8 +229,14 @@ func blocklistItem(name string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
trackCmd.Flags().BoolVarP(&trackVerboseLoggingFlag, "verbose", "v", false, "log which files are being tracked and modified")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
trackCmd.Flags().BoolVarP(&trackDryRunFlag, "dry-run", "d", false, "preview results of running `git lfs track`")
|
cmd := &cobra.Command{
|
||||||
|
Use: "track",
|
||||||
RootCmd.AddCommand(trackCmd)
|
Run: trackCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&trackVerboseLoggingFlag, "verbose", "v", false, "log which files are being tracked and modified")
|
||||||
|
cmd.Flags().BoolVarP(&trackDryRunFlag, "dry-run", "d", false, "preview results of running `git lfs track`")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,31 +9,29 @@ import (
|
|||||||
|
|
||||||
// TODO: Remove for Git LFS v2.0 https://github.com/github/git-lfs/issues/839
|
// TODO: Remove for Git LFS v2.0 https://github.com/github/git-lfs/issues/839
|
||||||
|
|
||||||
var (
|
|
||||||
// uninitCmd removes any configuration and hooks set by Git LFS.
|
// uninitCmd removes any configuration and hooks set by Git LFS.
|
||||||
uninitCmd = &cobra.Command{
|
|
||||||
Use: "uninit",
|
|
||||||
Run: uninitCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
// uninitHooksCmd removes any hooks created by Git LFS.
|
|
||||||
uninitHooksCmd = &cobra.Command{
|
|
||||||
Use: "hooks",
|
|
||||||
Run: uninitHooksCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func uninitCommand(cmd *cobra.Command, args []string) {
|
func uninitCommand(cmd *cobra.Command, args []string) {
|
||||||
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs uninit' is deprecated. Use 'git lfs uninstall' now.\n")
|
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs uninit' is deprecated. Use 'git lfs uninstall' now.\n")
|
||||||
uninstallCommand(cmd, args)
|
uninstallCommand(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uninitHooksCmd removes any hooks created by Git LFS.
|
||||||
func uninitHooksCommand(cmd *cobra.Command, args []string) {
|
func uninitHooksCommand(cmd *cobra.Command, args []string) {
|
||||||
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs uninit' is deprecated. Use 'git lfs uninstall' now.\n")
|
fmt.Fprintf(os.Stderr, "WARNING: 'git lfs uninit' is deprecated. Use 'git lfs uninstall' now.\n")
|
||||||
uninstallHooksCommand(cmd, args)
|
uninstallHooksCommand(cmd, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
uninitCmd.AddCommand(uninitHooksCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(uninitCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "uninit",
|
||||||
|
Run: uninitCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(&cobra.Command{
|
||||||
|
Use: "hooks",
|
||||||
|
Run: uninitHooksCommand,
|
||||||
|
})
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -5,20 +5,7 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
// uninstallCmd removes any configuration and hooks set by Git LFS.
|
// uninstallCmd removes any configuration and hooks set by Git LFS.
|
||||||
uninstallCmd = &cobra.Command{
|
|
||||||
Use: "uninstall",
|
|
||||||
Run: uninstallCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
// uninstallHooksCmd removes any hooks created by Git LFS.
|
|
||||||
uninstallHooksCmd = &cobra.Command{
|
|
||||||
Use: "hooks",
|
|
||||||
Run: uninstallHooksCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func uninstallCommand(cmd *cobra.Command, args []string) {
|
func uninstallCommand(cmd *cobra.Command, args []string) {
|
||||||
if err := lfs.UninstallFilters(); err != nil {
|
if err := lfs.UninstallFilters(); err != nil {
|
||||||
Error(err.Error())
|
Error(err.Error())
|
||||||
@ -31,6 +18,7 @@ func uninstallCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// uninstallHooksCmd removes any hooks created by Git LFS.
|
||||||
func uninstallHooksCommand(cmd *cobra.Command, args []string) {
|
func uninstallHooksCommand(cmd *cobra.Command, args []string) {
|
||||||
if err := lfs.UninstallHooks(); err != nil {
|
if err := lfs.UninstallHooks(); err != nil {
|
||||||
Error(err.Error())
|
Error(err.Error())
|
||||||
@ -40,6 +28,16 @@ func uninstallHooksCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
uninstallCmd.AddCommand(uninstallHooksCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(uninstallCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "uninstall",
|
||||||
|
Run: uninstallCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.AddCommand(&cobra.Command{
|
||||||
|
Use: "hooks",
|
||||||
|
Run: uninstallHooksCommand,
|
||||||
|
})
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -16,10 +16,6 @@ var (
|
|||||||
errLockAmbiguous = errors.New("lfs: multiple locks found; ambiguous")
|
errLockAmbiguous = errors.New("lfs: multiple locks found; ambiguous")
|
||||||
|
|
||||||
unlockCmdFlags unlockFlags
|
unlockCmdFlags unlockFlags
|
||||||
unlockCmd = &cobra.Command{
|
|
||||||
Use: "unlock",
|
|
||||||
Run: unlockCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// unlockFlags holds the flags given to the `git lfs unlock` command
|
// unlockFlags holds the flags given to the `git lfs unlock` command
|
||||||
@ -97,12 +93,19 @@ func lockIdFromPath(path string) (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
unlockCmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
if !isCommandEnabled(cfg, "locks") {
|
||||||
unlockCmd.Flags().StringVarP(&unlockCmdFlags.Id, "id", "i", "", "unlock a lock by its ID")
|
return nil
|
||||||
unlockCmd.Flags().BoolVarP(&unlockCmdFlags.Force, "force", "f", false, "forcibly break another user's lock(s)")
|
|
||||||
|
|
||||||
if isCommandEnabled(cfg, "locks") {
|
|
||||||
RootCmd.AddCommand(unlockCmd)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "unlock",
|
||||||
|
Run: unlockCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().StringVarP(&lockRemote, "remote", "r", cfg.CurrentRemote, lockRemoteHelp)
|
||||||
|
cmd.Flags().StringVarP(&unlockCmdFlags.Id, "id", "i", "", "unlock a lock by its ID")
|
||||||
|
cmd.Flags().BoolVarP(&unlockCmdFlags.Force, "force", "f", false, "forcibly break another user's lock(s)")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,6 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
untrackCmd = &cobra.Command{
|
|
||||||
Use: "untrack",
|
|
||||||
Run: untrackCommand,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
// untrackCommand takes a list of paths as an argument, and removes each path from the
|
// untrackCommand takes a list of paths as an argument, and removes each path from the
|
||||||
// default attributes file (.gitattributes), if it exists.
|
// default attributes file (.gitattributes), if it exists.
|
||||||
func untrackCommand(cmd *cobra.Command, args []string) {
|
func untrackCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -82,5 +75,10 @@ func removePath(path string, args []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(untrackCmd)
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
|
return &cobra.Command{
|
||||||
|
Use: "untrack",
|
||||||
|
Run: untrackCommand,
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,11 +9,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
updateCmd = &cobra.Command{
|
|
||||||
Use: "update",
|
|
||||||
Run: updateCommand,
|
|
||||||
}
|
|
||||||
|
|
||||||
updateForce = false
|
updateForce = false
|
||||||
updateManual = false
|
updateManual = false
|
||||||
)
|
)
|
||||||
@ -59,7 +54,13 @@ func updateCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
updateCmd.Flags().BoolVarP(&updateForce, "force", "f", false, "Overwrite existing hooks.")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
updateCmd.Flags().BoolVarP(&updateManual, "manual", "m", false, "Print instructions for manual install.")
|
cmd := &cobra.Command{
|
||||||
RootCmd.AddCommand(updateCmd)
|
Use: "update",
|
||||||
|
Run: updateCommand,
|
||||||
|
}
|
||||||
|
cmd.Flags().BoolVarP(&updateForce, "force", "f", false, "Overwrite existing hooks.")
|
||||||
|
cmd.Flags().BoolVarP(&updateManual, "manual", "m", false, "Print instructions for manual install.")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,6 @@ import (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
lovesComics bool
|
lovesComics bool
|
||||||
|
|
||||||
versionCmd = &cobra.Command{
|
|
||||||
Use: "version",
|
|
||||||
Run: versionCommand,
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func versionCommand(cmd *cobra.Command, args []string) {
|
func versionCommand(cmd *cobra.Command, args []string) {
|
||||||
@ -23,6 +18,13 @@ func versionCommand(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
versionCmd.Flags().BoolVarP(&lovesComics, "comics", "c", false, "easter egg")
|
RegisterSubcommand(func() *cobra.Command {
|
||||||
RootCmd.AddCommand(versionCmd)
|
cmd := &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Run: versionCommand,
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd.Flags().BoolVarP(&lovesComics, "comics", "c", false, "easter egg")
|
||||||
|
return cmd
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/github/git-lfs/api"
|
"github.com/github/git-lfs/api"
|
||||||
@ -18,6 +19,7 @@ import (
|
|||||||
"github.com/github/git-lfs/httputil"
|
"github.com/github/git-lfs/httputil"
|
||||||
"github.com/github/git-lfs/lfs"
|
"github.com/github/git-lfs/lfs"
|
||||||
"github.com/github/git-lfs/tools"
|
"github.com/github/git-lfs/tools"
|
||||||
|
"github.com/github/git-lfs/transfer"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -33,19 +35,52 @@ var (
|
|||||||
ErrorBuffer = &bytes.Buffer{}
|
ErrorBuffer = &bytes.Buffer{}
|
||||||
ErrorWriter = io.MultiWriter(os.Stderr, ErrorBuffer)
|
ErrorWriter = io.MultiWriter(os.Stderr, ErrorBuffer)
|
||||||
OutputWriter = io.MultiWriter(os.Stdout, ErrorBuffer)
|
OutputWriter = io.MultiWriter(os.Stdout, ErrorBuffer)
|
||||||
RootCmd = &cobra.Command{
|
ManPages = make(map[string]string, 20)
|
||||||
|
cfg *config.Configuration
|
||||||
|
subcommandFuncs []func() *cobra.Command
|
||||||
|
subcommandMu sync.Mutex
|
||||||
|
|
||||||
|
includeArg string
|
||||||
|
excludeArg string
|
||||||
|
)
|
||||||
|
|
||||||
|
func Run() {
|
||||||
|
cfg = config.Config
|
||||||
|
|
||||||
|
root := &cobra.Command{
|
||||||
Use: "git-lfs",
|
Use: "git-lfs",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
versionCommand(cmd, args)
|
versionCommand(cmd, args)
|
||||||
cmd.Usage()
|
cmd.Usage()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
ManPages = make(map[string]string, 20)
|
|
||||||
cfg = config.Config
|
|
||||||
|
|
||||||
includeArg string
|
// Set up help/usage funcs based on manpage text
|
||||||
excludeArg string
|
root.SetHelpFunc(help)
|
||||||
)
|
root.SetHelpTemplate("{{.UsageString}}")
|
||||||
|
root.SetUsageFunc(usage)
|
||||||
|
|
||||||
|
for _, f := range subcommandFuncs {
|
||||||
|
if cmd := f(); cmd != nil {
|
||||||
|
root.AddCommand(cmd)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
root.Execute()
|
||||||
|
httputil.LogHttpStats(cfg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func RegisterSubcommand(fn func() *cobra.Command) {
|
||||||
|
subcommandMu.Lock()
|
||||||
|
subcommandFuncs = append(subcommandFuncs, fn)
|
||||||
|
subcommandMu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// TransferManifest builds a transfer.Manifest from the commands package global
|
||||||
|
// cfg var.
|
||||||
|
func TransferManifest() *transfer.Manifest {
|
||||||
|
return transfer.ConfigureManifest(transfer.NewManifest(), cfg)
|
||||||
|
}
|
||||||
|
|
||||||
// Error prints a formatted message to Stderr. It also gets printed to the
|
// Error prints a formatted message to Stderr. It also gets printed to the
|
||||||
// panic log if one is created for this command.
|
// panic log if one is created for this command.
|
||||||
@ -108,11 +143,6 @@ func Panic(err error, format string, args ...interface{}) {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() {
|
|
||||||
RootCmd.Execute()
|
|
||||||
httputil.LogHttpStats(cfg)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Cleanup() {
|
func Cleanup() {
|
||||||
if err := lfs.ClearTempObjects(); err != nil {
|
if err := lfs.ClearTempObjects(); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Error clearing old temp files: %s\n", err)
|
fmt.Fprintf(os.Stderr, "Error clearing old temp files: %s\n", err)
|
||||||
@ -225,7 +255,7 @@ func logPanicToWriter(w io.Writer, loggedError error) {
|
|||||||
fmt.Fprintln(w, "\nENV:")
|
fmt.Fprintln(w, "\nENV:")
|
||||||
|
|
||||||
// log the environment
|
// log the environment
|
||||||
for _, env := range lfs.Environ() {
|
for _, env := range lfs.Environ(cfg, TransferManifest()) {
|
||||||
fmt.Fprintln(w, env)
|
fmt.Fprintln(w, env)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -287,8 +317,4 @@ func isCommandEnabled(cfg *config.Configuration, cmd string) bool {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
log.SetOutput(ErrorWriter)
|
log.SetOutput(ErrorWriter)
|
||||||
// Set up help/usage funcs based on manpage text
|
|
||||||
RootCmd.SetHelpFunc(help)
|
|
||||||
RootCmd.SetHelpTemplate("{{.UsageString}}")
|
|
||||||
RootCmd.SetUsageFunc(usage)
|
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ package config
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -68,11 +69,12 @@ type Configuration struct {
|
|||||||
IsLoggingStats bool
|
IsLoggingStats bool
|
||||||
|
|
||||||
loading sync.Mutex // guards initialization of gitConfig and remotes
|
loading sync.Mutex // guards initialization of gitConfig and remotes
|
||||||
origConfig map[string]string
|
|
||||||
remotes []string
|
remotes []string
|
||||||
extensions map[string]Extension
|
extensions map[string]Extension
|
||||||
manualEndpoint *Endpoint
|
manualEndpoint *Endpoint
|
||||||
parsedNetrc netrcfinder
|
parsedNetrc netrcfinder
|
||||||
|
urlAliasesMap map[string]string
|
||||||
|
urlAliasMu sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Configuration {
|
func New() *Configuration {
|
||||||
@ -439,6 +441,50 @@ func (c *Configuration) AllGitConfig() map[string]string {
|
|||||||
return c.gitConfig
|
return c.gitConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Configuration) urlAliases() map[string]string {
|
||||||
|
c.urlAliasMu.Lock()
|
||||||
|
defer c.urlAliasMu.Unlock()
|
||||||
|
|
||||||
|
if c.urlAliasesMap == nil {
|
||||||
|
c.urlAliasesMap = make(map[string]string)
|
||||||
|
prefix := "url."
|
||||||
|
suffix := ".insteadof"
|
||||||
|
for gitkey, gitval := range c.AllGitConfig() {
|
||||||
|
if strings.HasPrefix(gitkey, prefix) && strings.HasSuffix(gitkey, suffix) {
|
||||||
|
if _, ok := c.urlAliasesMap[gitval]; ok {
|
||||||
|
fmt.Fprintf(os.Stderr, "WARNING: Multiple 'url.*.insteadof' keys with the same alias: %q\n", gitval)
|
||||||
|
}
|
||||||
|
c.urlAliasesMap[gitval] = gitkey[len(prefix) : len(gitkey)-len(suffix)]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.urlAliasesMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReplaceUrlAlias returns a url with a prefix from a `url.*.insteadof` git
|
||||||
|
// config setting. If multiple aliases match, use the longest one.
|
||||||
|
// See https://git-scm.com/docs/git-config for Git's docs.
|
||||||
|
func (c *Configuration) ReplaceUrlAlias(rawurl string) string {
|
||||||
|
var longestalias string
|
||||||
|
aliases := c.urlAliases()
|
||||||
|
for alias, _ := range aliases {
|
||||||
|
if !strings.HasPrefix(rawurl, alias) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if longestalias < alias {
|
||||||
|
longestalias = alias
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(longestalias) > 0 {
|
||||||
|
return aliases[longestalias] + rawurl[len(longestalias):]
|
||||||
|
}
|
||||||
|
|
||||||
|
return rawurl
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Configuration) FetchPruneConfig() FetchPruneConfig {
|
func (c *Configuration) FetchPruneConfig() FetchPruneConfig {
|
||||||
f := &FetchPruneConfig{
|
f := &FetchPruneConfig{
|
||||||
FetchRecentRefsDays: 7,
|
FetchRecentRefsDays: 7,
|
||||||
@ -481,30 +527,3 @@ func (c *Configuration) loadGitConfig() bool {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX(taylor): remove mutability
|
|
||||||
func (c *Configuration) SetConfig(key, value string) {
|
|
||||||
if c.loadGitConfig() {
|
|
||||||
c.loading.Lock()
|
|
||||||
c.origConfig = make(map[string]string)
|
|
||||||
for k, v := range c.gitConfig {
|
|
||||||
c.origConfig[k] = v
|
|
||||||
}
|
|
||||||
c.loading.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
c.gitConfig[key] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX(taylor): remove mutability
|
|
||||||
func (c *Configuration) ResetConfig() {
|
|
||||||
c.loading.Lock()
|
|
||||||
c.gitConfig = make(map[string]string)
|
|
||||||
if gf, ok := c.Git.Fetcher.(*GitFetcher); ok {
|
|
||||||
gf.vals = c.gitConfig
|
|
||||||
}
|
|
||||||
for k, v := range c.origConfig {
|
|
||||||
c.gitConfig[k] = v
|
|
||||||
}
|
|
||||||
c.loading.Unlock()
|
|
||||||
}
|
|
||||||
|
@ -48,6 +48,7 @@ func NewEndpointFromCloneURLWithConfig(url string, c *Configuration) Endpoint {
|
|||||||
|
|
||||||
// NewEndpointWithConfig initializes a new Endpoint for a given URL.
|
// NewEndpointWithConfig initializes a new Endpoint for a given URL.
|
||||||
func NewEndpointWithConfig(rawurl string, c *Configuration) Endpoint {
|
func NewEndpointWithConfig(rawurl string, c *Configuration) Endpoint {
|
||||||
|
rawurl = c.ReplaceUrlAlias(rawurl)
|
||||||
u, err := url.Parse(rawurl)
|
u, err := url.Parse(rawurl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Endpoint{Url: EndpointUrlUnknown}
|
return Endpoint{Url: EndpointUrlUnknown}
|
||||||
|
44
lfs/lfs.go
44
lfs/lfs.go
@ -67,15 +67,17 @@ func ObjectExistsOfSize(oid string, size int64) bool {
|
|||||||
return tools.FileExistsOfSize(path, size)
|
return tools.FileExistsOfSize(path, size)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Environ() []string {
|
func Environ(cfg *config.Configuration, manifest *transfer.Manifest) []string {
|
||||||
manifest := transfer.ConfigureManifest(transfer.NewManifest(), config.Config)
|
|
||||||
osEnviron := os.Environ()
|
osEnviron := os.Environ()
|
||||||
env := make([]string, 0, len(osEnviron)+7)
|
env := make([]string, 0, len(osEnviron)+7)
|
||||||
|
|
||||||
dltransfers := manifest.GetDownloadAdapterNames()
|
dltransfers := manifest.GetDownloadAdapterNames()
|
||||||
sort.Strings(dltransfers)
|
sort.Strings(dltransfers)
|
||||||
ultransfers := manifest.GetUploadAdapterNames()
|
ultransfers := manifest.GetUploadAdapterNames()
|
||||||
sort.Strings(ultransfers)
|
sort.Strings(ultransfers)
|
||||||
|
|
||||||
|
fetchPruneConfig := cfg.FetchPruneConfig()
|
||||||
|
|
||||||
env = append(env,
|
env = append(env,
|
||||||
fmt.Sprintf("LocalWorkingDir=%s", config.LocalWorkingDir),
|
fmt.Sprintf("LocalWorkingDir=%s", config.LocalWorkingDir),
|
||||||
fmt.Sprintf("LocalGitDir=%s", config.LocalGitDir),
|
fmt.Sprintf("LocalGitDir=%s", config.LocalGitDir),
|
||||||
@ -83,30 +85,30 @@ func Environ() []string {
|
|||||||
fmt.Sprintf("LocalMediaDir=%s", LocalMediaDir()),
|
fmt.Sprintf("LocalMediaDir=%s", LocalMediaDir()),
|
||||||
fmt.Sprintf("LocalReferenceDir=%s", config.LocalReferenceDir),
|
fmt.Sprintf("LocalReferenceDir=%s", config.LocalReferenceDir),
|
||||||
fmt.Sprintf("TempDir=%s", TempDir()),
|
fmt.Sprintf("TempDir=%s", TempDir()),
|
||||||
fmt.Sprintf("ConcurrentTransfers=%d", config.Config.ConcurrentTransfers()),
|
fmt.Sprintf("ConcurrentTransfers=%d", cfg.ConcurrentTransfers()),
|
||||||
fmt.Sprintf("TusTransfers=%v", config.Config.TusTransfersAllowed()),
|
fmt.Sprintf("TusTransfers=%v", cfg.TusTransfersAllowed()),
|
||||||
fmt.Sprintf("BasicTransfersOnly=%v", config.Config.BasicTransfersOnly()),
|
fmt.Sprintf("BasicTransfersOnly=%v", cfg.BasicTransfersOnly()),
|
||||||
fmt.Sprintf("BatchTransfer=%v", config.Config.BatchTransfer()),
|
fmt.Sprintf("BatchTransfer=%v", cfg.BatchTransfer()),
|
||||||
fmt.Sprintf("SkipDownloadErrors=%v", config.Config.SkipDownloadErrors()),
|
fmt.Sprintf("SkipDownloadErrors=%v", cfg.SkipDownloadErrors()),
|
||||||
fmt.Sprintf("FetchRecentAlways=%v", config.Config.FetchPruneConfig().FetchRecentAlways),
|
fmt.Sprintf("FetchRecentAlways=%v", fetchPruneConfig.FetchRecentAlways),
|
||||||
fmt.Sprintf("FetchRecentRefsDays=%d", config.Config.FetchPruneConfig().FetchRecentRefsDays),
|
fmt.Sprintf("FetchRecentRefsDays=%d", fetchPruneConfig.FetchRecentRefsDays),
|
||||||
fmt.Sprintf("FetchRecentCommitsDays=%d", config.Config.FetchPruneConfig().FetchRecentCommitsDays),
|
fmt.Sprintf("FetchRecentCommitsDays=%d", fetchPruneConfig.FetchRecentCommitsDays),
|
||||||
fmt.Sprintf("FetchRecentRefsIncludeRemotes=%v", config.Config.FetchPruneConfig().FetchRecentRefsIncludeRemotes),
|
fmt.Sprintf("FetchRecentRefsIncludeRemotes=%v", fetchPruneConfig.FetchRecentRefsIncludeRemotes),
|
||||||
fmt.Sprintf("PruneOffsetDays=%d", config.Config.FetchPruneConfig().PruneOffsetDays),
|
fmt.Sprintf("PruneOffsetDays=%d", fetchPruneConfig.PruneOffsetDays),
|
||||||
fmt.Sprintf("PruneVerifyRemoteAlways=%v", config.Config.FetchPruneConfig().PruneVerifyRemoteAlways),
|
fmt.Sprintf("PruneVerifyRemoteAlways=%v", fetchPruneConfig.PruneVerifyRemoteAlways),
|
||||||
fmt.Sprintf("PruneRemoteName=%s", config.Config.FetchPruneConfig().PruneRemoteName),
|
fmt.Sprintf("PruneRemoteName=%s", fetchPruneConfig.PruneRemoteName),
|
||||||
fmt.Sprintf("AccessDownload=%s", config.Config.Access("download")),
|
fmt.Sprintf("AccessDownload=%s", cfg.Access("download")),
|
||||||
fmt.Sprintf("AccessUpload=%s", config.Config.Access("upload")),
|
fmt.Sprintf("AccessUpload=%s", cfg.Access("upload")),
|
||||||
fmt.Sprintf("DownloadTransfers=%s", strings.Join(dltransfers, ",")),
|
fmt.Sprintf("DownloadTransfers=%s", strings.Join(dltransfers, ",")),
|
||||||
fmt.Sprintf("UploadTransfers=%s", strings.Join(ultransfers, ",")),
|
fmt.Sprintf("UploadTransfers=%s", strings.Join(ultransfers, ",")),
|
||||||
)
|
)
|
||||||
if len(config.Config.FetchExcludePaths()) > 0 {
|
if len(cfg.FetchExcludePaths()) > 0 {
|
||||||
env = append(env, fmt.Sprintf("FetchExclude=%s", strings.Join(config.Config.FetchExcludePaths(), ", ")))
|
env = append(env, fmt.Sprintf("FetchExclude=%s", strings.Join(cfg.FetchExcludePaths(), ", ")))
|
||||||
}
|
}
|
||||||
if len(config.Config.FetchIncludePaths()) > 0 {
|
if len(cfg.FetchIncludePaths()) > 0 {
|
||||||
env = append(env, fmt.Sprintf("FetchInclude=%s", strings.Join(config.Config.FetchIncludePaths(), ", ")))
|
env = append(env, fmt.Sprintf("FetchInclude=%s", strings.Join(cfg.FetchIncludePaths(), ", ")))
|
||||||
}
|
}
|
||||||
for _, ext := range config.Config.Extensions() {
|
for _, ext := range cfg.Extensions() {
|
||||||
env = append(env, fmt.Sprintf("Extension[%d]=%s", ext.Priority, ext.Name))
|
env = append(env, fmt.Sprintf("Extension[%d]=%s", ext.Priority, ext.Name))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,3 +149,56 @@ begin_test "extension config (with gitconfig)"
|
|||||||
[ "$expected2" = "$(git lfs ext)" ]
|
[ "$expected2" = "$(git lfs ext)" ]
|
||||||
)
|
)
|
||||||
end_test
|
end_test
|
||||||
|
|
||||||
|
begin_test "url alias config"
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir url-alias
|
||||||
|
cd url-alias
|
||||||
|
|
||||||
|
git init
|
||||||
|
|
||||||
|
# When more than one insteadOf strings match a given URL, the longest match is used.
|
||||||
|
git config url."http://wrong-url/".insteadOf alias
|
||||||
|
git config url."http://actual-url/".insteadOf alias:
|
||||||
|
git config lfs.url alias:rest
|
||||||
|
git lfs env | tee env.log
|
||||||
|
grep "Endpoint=http://actual-url/rest (auth=none)" env.log
|
||||||
|
)
|
||||||
|
end_test
|
||||||
|
|
||||||
|
begin_test "ambiguous url alias"
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir url-alias-ambiguous
|
||||||
|
cd url-alias-ambiguous
|
||||||
|
|
||||||
|
git init
|
||||||
|
|
||||||
|
git config url."http://actual-url/".insteadOf alias:
|
||||||
|
git config url."http://dupe-url".insteadOf alias:
|
||||||
|
git config lfs.url alias:rest
|
||||||
|
git config -l | grep url
|
||||||
|
|
||||||
|
git lfs env 2>&1 | tee env2.log
|
||||||
|
grep "WARNING: Multiple 'url.*.insteadof'" env2.log
|
||||||
|
)
|
||||||
|
end_test
|
||||||
|
|
||||||
|
begin_test "url alias must be prefix"
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir url-alias-bad
|
||||||
|
cd url-alias-bad
|
||||||
|
|
||||||
|
git init
|
||||||
|
|
||||||
|
git config url."http://actual-url/".insteadOf alias:
|
||||||
|
git config lfs.url badalias:rest
|
||||||
|
git lfs env | tee env.log
|
||||||
|
grep "Endpoint=badalias:rest (auth=none)" env.log
|
||||||
|
)
|
||||||
|
end_test
|
||||||
|
@ -63,7 +63,7 @@ type customAdapterWorkerContext struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type customAdapterInitRequest struct {
|
type customAdapterInitRequest struct {
|
||||||
Event string `json:"Event"`
|
Event string `json:"event"`
|
||||||
Operation string `json:"operation"`
|
Operation string `json:"operation"`
|
||||||
Concurrent bool `json:"concurrent"`
|
Concurrent bool `json:"concurrent"`
|
||||||
ConcurrentTransfers int `json:"concurrenttransfers"`
|
ConcurrentTransfers int `json:"concurrenttransfers"`
|
||||||
|
Loading…
Reference in New Issue
Block a user