! Copyright (C) 2022 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: accessors assocs assocs.extras bootstrap.image calendar formatting http.client io io.encodings.utf8 io.launcher kernel math math.parser modern.html prettyprint random sequences sorting splitting zealot.factor ; IN: factor-bisect : git-ids-assoc ( -- assoc ) { "git" "log" "--format=format:%H %at" } utf8 stream-lines [ " " split1 string>number unix-time>timestamp ] H{ } map>assoc ; : get-build-ids ( arch -- seq ) "https://downloads.factorcode.org/images/build/" http-get nip "
" "
" replace string>html first children>> second children>> third children>> [ open-tag? ] filter [ props>> first second payload>> ] map [ length 30 < ] reject swap '[ [ _ ] dip subseq? ] filter [ "." split1-last nip ] map ; : platform-git-ids ( arch -- assoc ) [ git-ids-assoc ] dip get-build-ids rekey-new-assoc sift-values sort-values ; : build-image-download-name ( arch git-id -- str ) "https://downloads.factorcode.org/images/build/boot.%s.image.%s" sprintf ; : factorcode-boot-image-paths ( arch -- assoc ) [ platform-git-ids ] keep '[ [ _ ] 2dip [ build-image-download-name ] dip ] assoc-map ; : my-arch-boot-image-paths ( -- assoc ) my-arch-name factorcode-boot-image-paths ; : bisect-middle-factor ( seq cmd -- ? ) ! [ [ length 2 /i ] keep ] dip [ [ length 1 - ] keep ] dip '[ nth first 40 tail* dup ... flush _ bisect-new-factor "t" = ] 2keep swap cut ? ; : build-all-factors ( seq -- ) [ first 40 tail* dup ... flush build-new-factor ] each ; : bisect-factor ( cmd -- git-id ) [ my-arch-boot-image-paths ] dip bisect-middle-factor ;%