<commit_before>$bucketsdir = "$scoopdir\buckets"

function bucketdir($name) {
	if(!$name) { return relpath "..\bucket" } # main bucket

	"$bucketsdir\$name"
}

function known_bucket_repo($name) {
	$dir = versiondir 'scoop' 'current'
	$json = "$dir\buckets.json"
	$buckets = gc $json -raw | convertfrom-json -ea stop
	$buckets.$name
}

function apps_in_bucket($dir) {
	gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' }
}

function buckets {
	$buckets = @()
	if(test-path $bucketsdir) {
		gci $bucketsdir | % { $buckets += $_.name }
	}
	$buckets
}

function find_manifest($app) {
	@($null) + @(buckets) | % { # null for main bucket
		$manifest = manifest $app $_
		if($manifest) { return $manifest, $_ }
	}
}

<#
# convert an object to a hashtable<commit_msg>handle app found in more than one bucket (just return first, rather than all)<commit_after>$bucketsdir = "$scoopdir\buckets"

function bucketdir($name) {
	if(!$name) { return relpath "..\bucket" } # main bucket

	"$bucketsdir\$name"
}

function known_bucket_repo($name) {
	$dir = versiondir 'scoop' 'current'
	$json = "$dir\buckets.json"
	$buckets = gc $json -raw | convertfrom-json -ea stop
	$buckets.$name
}

function apps_in_bucket($dir) {
	gci $dir | ? { $_.name.endswith('.json') } | % { $_ -replace '.json$', '' }
}

function buckets {
	$buckets = @()
	if(test-path $bucketsdir) {
		gci $bucketsdir | % { $buckets += $_.name }
	}
	$buckets
}

function find_manifest($app) {
	$buckets = @($null) + @(buckets) # null for main bucket
	foreach($bucket in $buckets) {
		$manifest = manifest $app $bucket
		if($manifest) {	return $manifest, $bucket }
	}
}

<#
# convert an object to a hashtable
{'fraction_non_alphanumeric': 0.1794871794871795, 'fraction_numerical': 0.0, 'mean_word_length': 4.054216867469879, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7271007', 'n_tokens_mistral': 682, 'n_tokens_neox': 626, 'n_words': 146}