Skip to content

Commit

Permalink
Merge pull request #23 from apiiro/talfin/missing-tree
Browse files Browse the repository at this point in the history
Handle missing tree error
  • Loading branch information
TalfinApiiro authored Jan 23, 2024
2 parents b973616 + 98f8416 commit e15eac9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Tool to create a git revision snapshot for an existing repository clone.

```
NAME:
git-snap - 1.18 - Create a git revision snapshot for an existing repository clone. Symbolic link files will be omitted.
git-snap - 1.19 - Create a git revision snapshot for an existing repository clone. Symbolic link files will be omitted.
USAGE:
git-snap --src value --rev value --out value [optional flags]
Expand Down
5 changes: 4 additions & 1 deletion git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,10 @@ func (provider *repositoryProvider) snapshot(repository *git.Repository, commit

tree, err := commit.Tree()
if err != nil {
return 0, fmt.Errorf("failed to get tree of commit '%v': %v", commit.Hash, err)
return 0, util.ErrorWithCode{
StatusCode: util.ERROR_TREE_NOT_FOUND,
InternalError: fmt.Errorf("failed to get tree of commit '%v': %v", commit.Hash, err),
}
}
count := 0

Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/urfave/cli/v2"
)

const VERSION = "1.18"
const VERSION = "1.19"

func main() {
cli.AppHelpTemplate =
Expand All @@ -33,6 +33,7 @@ EXIT CODES:
205 Provided revision could not be found
206 Double check for files discrepancy failed
207 HEAD ref not found
208 tree not found
1 Any other error
`

Expand Down
1 change: 1 addition & 0 deletions util/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const (
ERROR_NO_REVISION = 205
ERROR_FILES_DISCREPANCY = 206
ERROR_HEAD_REF_NOT_FOUND = 207
ERROR_TREE_NOT_FOUND = 208
ERROR_PATH_TOO_LONG = 101
)

Expand Down

0 comments on commit e15eac9

Please sign in to comment.