Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Commit

Permalink
Only sync published releases.
Browse files Browse the repository at this point in the history
The current code fails if a repository contains unpublished/ draft releases due
to a missing publish date.
  • Loading branch information
MaineC committed Sep 13, 2018
1 parent bc6138d commit 2793463
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
18 changes: 10 additions & 8 deletions github-sync-tng/release_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ def db_insert_releases(db, org, repo, releases)
end
end


db[
"INSERT INTO releases (
org, repo, id, html_url, tarball_url, zipball_url, tag_name, name, body, created_at, published_at, author
)
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )",
org, repo, release.id, release.html_url, release.tarball_url, release.zipball_url, release.tag_name, release.name, release.body, release.created_at.to_s,
release.published_at.to_s, author].insert
# only include releases that were published
if(release.published_at)
db[
"INSERT INTO releases (
org, repo, id, html_url, tarball_url, zipball_url, tag_name, name, body, created_at, published_at, author
)
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )",
org, repo, release.id, release.html_url, release.tarball_url, release.zipball_url, release.tag_name, release.name, release.body, release.created_at.to_s,
release.published_at.to_s, author].insert
end
end
end
end
Expand Down
17 changes: 10 additions & 7 deletions github-sync/db_releases/sync-releases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@ def db_insert_releases(db, org, repo, releases)
end
end

db[
"INSERT INTO releases (
org, repo, id, html_url, tarball_url, zipball_url, tag_name, name, body, created_at, published_at, author
)
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )",
org, repo, release.id, release.html_url, release.tarball_url, release.zipball_url, release.tag_name,
release.name, release.body, release.created_at.to_s, release.published_at.to_s, author].insert
# only track published releases
if(release.published_at)
db[
"INSERT INTO releases (
org, repo, id, html_url, tarball_url, zipball_url, tag_name, name, body, created_at, published_at, author
)
VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )",
org, repo, release.id, release.html_url, release.tarball_url, release.zipball_url, release.tag_name,
release.name, release.body, release.created_at.to_s, release.published_at.to_s, author].insert
end
end
end

Expand Down

0 comments on commit 2793463

Please sign in to comment.