-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
1,161 additions
and
377 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,4 +87,6 @@ tags | |
/.idea/ | ||
/.vscode/ | ||
*.iml | ||
data/ | ||
|
||
# Trumpet related settings | ||
.trumpet |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright © 2018 One Concern | ||
|
||
package cmd | ||
|
||
import ( | ||
"log" | ||
"path/filepath" | ||
|
||
"github.com/oneconcern/trumpet" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// addCmd represents the add command | ||
var addCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add a file to a bundle for commit", | ||
Long: `Add a file or group of files to a bundle for commit. | ||
This command supports providing one or more glob patterns | ||
`, | ||
Args: cobra.MinimumNArgs(1), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
tpt, err := trumpet.New("") | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
repo, err := tpt.GetRepo("hello-there") | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
for _, arg := range args { | ||
pths, err := filepath.Glob(arg) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
for _, pth := range pths { | ||
addBlob, err := trumpet.UnstagedFilePath(pth) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
hash, isNew, err := repo.Stage().Add(addBlob) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
|
||
log.Println("added file", hash, "is new:", isNew) | ||
} | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
bundleCmd.AddCommand(addCmd) | ||
for i := 1; i < 100; i++ { | ||
addCmd.MarkZshCompPositionalArgumentFile(i, "*") | ||
} | ||
addRepoNameOption(addCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright © 2018 One Concern | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// fileAddCmd represents the add command | ||
var fileAddCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "Add a file to upload", | ||
Long: `Add a file to the stage of a bundle, this does not yet upload the file. | ||
This operation adds the file to be uploaded. At this stage we create a fingerprint for this file. | ||
The file will be copied to a deduplicated staging area with its hash as name | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
fmt.Println("add called") | ||
}, | ||
} | ||
|
||
func init() { | ||
fileCmd.AddCommand(fileAddCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// fileAddCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// fileAddCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.