Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the pixlet community target-determinator command #1063

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/community/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
func init() {
CommunityCmd.AddCommand(ListIconsCmd)
CommunityCmd.AddCommand(LoadAppCmd)
CommunityCmd.AddCommand(TargetDeterminatorCmd)
CommunityCmd.AddCommand(ValidateIconsCmd)
CommunityCmd.AddCommand(ValidateManifestCmd)
}
Expand Down
92 changes: 0 additions & 92 deletions cmd/community/targetdeterminator.go

This file was deleted.

64 changes: 0 additions & 64 deletions tools/repo/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

"github.com/gitsight/go-vcsurl"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object"
)

// IsInRepo determines if the provided directory is in the provided git
Expand Down Expand Up @@ -60,65 +58,3 @@ func RepoRoot(dir string) (string, error) {

return worktree.Filesystem.Root(), nil
}

func DetermineChanges(dir string, oldCommit string, newCommit string) ([]string, error) {
// Load the repo.
repo, err := git.PlainOpenWithOptions(dir, &git.PlainOpenOptions{
DetectDotGit: true,
})
if err != nil {
return nil, fmt.Errorf("couldn't instantiate repo: %w", err)
}

// Do a bunch of plumbing to get these commits usable for go-git
oldHash, err := repo.ResolveRevision(plumbing.Revision(oldCommit))
if err != nil {
return nil, fmt.Errorf("couldn't parse old commit: %w", err)
}
newHash, err := repo.ResolveRevision(plumbing.Revision(newCommit))
if err != nil {
return nil, fmt.Errorf("couldn't parse new commit: %w", err)
}
old, err := repo.CommitObject(*oldHash)
if err != nil {
return nil, fmt.Errorf("couldn't find old commit: %w", err)
}
new, err := repo.CommitObject(*newHash)
if err != nil {
return nil, fmt.Errorf("couldn't find new commit: %w", err)
}
oldTree, err := old.Tree()
if err != nil {
return nil, fmt.Errorf("couldn't generate tree for old commit: %w", err)
}
newTree, err := new.Tree()
if err != nil {
return nil, fmt.Errorf("couldn't generate tree for new commit: %w", err)
}

// Diff the two trees to determine what changed.
changes, err := oldTree.Diff(newTree)
if err != nil {
return nil, fmt.Errorf("couldn't get changes between commits: %w", err)
}

// Create a unique list of changed files.
changedFiles := []string{}
for _, change := range changes {
changedFiles = append(changedFiles, getChangeName(change))
}

return changedFiles, nil
}

func getChangeName(change *object.Change) string {
var empty = object.ChangeEntry{}

// Use the To field for Inserts and Modifications.
if change.To != empty {
return change.To.Name
}

// The From field for Deletes.
return change.From.Name
}
Loading