Skip to content

Commit

Permalink
Get the last events
Browse files Browse the repository at this point in the history
* technically this isn't crawling all events
- If someone complains that the last force push event is outside
the last event page and within the timeframe view and doesn't want
to use a tighter timeframe, I can fix this code to actually crawl
all of the events (the code is able to do so fairly trivially),
but I'm hoping on average that this shortcut is ok.
  • Loading branch information
jsoref committed Feb 21, 2020
1 parent a623cff commit e584b83
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions check-pull-requests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,46 @@ cat "$pulls" | jq -c '.[]'|jq -c -r '{
base_sha: .base.sha,
clone_url: .head.repo.clone_url,
merge_commit_sha: .merge_commit_sha,
updated_at: .updated_at,
created_at: .created_at,
issue_url: .issue_url,
commits_url: .commits_url,
comments_url: .comments_url
} | @base64' > "$escaped"

get_created_from_events() {
rm -f "$headers"
created_at=$(curl -s -S \
-H "Authorization: token $GITHUB_TOKEN" \
--header "Content-Type: application/json" \
-D "$headers" \
"$1" |
jq -M -r '[ .[]|select (.event=="head_ref_force_pushed") ][-1].created_at')
if [ "$created_at" = "null" ]; then
created_time=0
else
created_time=$(date_to_epoch $created_at)
fi
if [ -e "$headers" ]; then
next_url=$(perl -ne 'next unless s/^Link: //;s/,\s+/\n/g; print "$1" if /<(.*)>; rel="last"/' $headers)
rm -f "$headers"
if [ -n "$next_url" ]; then
other_time=$(get_created_from_events "$next_url")
if [ "$created_time" -lt "$other_time" ]; then
created_time=$other_time
fi
fi
fi
echo "$created_time"
}

for a in $(cat "$escaped"); do
echo "$a" | base64 --decode | jq -r . > $pull
updated_at=$(cat $pull | jq -r .updated_at)
age=$(( $start - $(date_to_epoch $updated_at) ))
issue_url=$(cat $pull | jq -r .issue_url)
created_at=$(get_created_from_events "${issue_url}/events")
if [ "$created_at" -eq 0 ]; then
created_at=$(date_to_epoch $(cat $pull | jq -r .created_at))
fi
age=$(( $start - $created_at ))
if [ $age -gt $time_limit ]; then
continue
fi
Expand Down

1 comment on commit e584b83

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • timeframe
To accept these changes, run the following commands (They can be run anywhere with permissions to update the bucket.)
git clone --depth 1 ssh://git@github.com/check-spelling/check-spelling.git --single-branch --branch spelling-data metadata; cp metadata/whitelist.txt .
(
cat whitelist.txt;
echo "
timeframe
"
) | sort -u -f | grep . > new_whitelist.txt && mv new_whitelist.txt whitelist.txt
cp whitelist.txt metadata; (cd metadata; git commit whitelist.txt -m 'Updating whitelist'; git push)

Please sign in to comment.