Skip to content

Commit

Permalink
Remove the pixlet community target-determinator command (#1063)
Browse files Browse the repository at this point in the history
This was just a CI helper for the tidbyt/community repo. It doesn't have
to be part of Pixlet, and it stopped working correctly for apps that
contain subdirectories.
  • Loading branch information
rohansingh authored Apr 26, 2024
1 parent a228654 commit f4d5078
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 157 deletions.
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
}

0 comments on commit f4d5078

Please sign in to comment.