Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

donloads: show the installer/package release date #185

Merged
merged 1 commit into from

3 participants

@carlosmn

Yet Another Msygit Fix. Store the installer's release date as a
separate field, as it's not always the date that the version was
tagged.

This allows us to report the correct release date in the /download/win
page. Unfortunately the msysgit downloads aren't always uploaded to
github on the date that the installer has, so we need to parse it to
get the release date.


After the migration, the Mac page will still show the wrong date until the next rake downloads run, but the date issue for Mac is much less important than for Windows, which will have the right date from the start.

@sschuberth what do you think? as long as the filename format doesn't change, this should keep working. If the downloads on the github repo start getting the right timestamp, we can simplify this so we take it instead of parsing the filename.

@carlosmn carlosmn donloads: show the installer/package release date
Yet Another Msygit Fix. Store the installer's release date as a
separate field, as it's not always the date that the version was
tagged.

This allows us to report the correct release date in the /download/win
page. Unfortunately the msysgit downloads aren't always uploaded to
github on the date that the installer has, so we need to parse it to
get the release date.
2ba9951
@bry4n bry4n merged commit adbbe80 into git:master

1 check failed

Details default The Travis build failed
@bry4n
Owner

Merged, thanks! :+1:

@sschuberth

@carlosmn: So, I was about to review this as requested, but then bry4n has already merged. I'm not too familiar with Ruby, but I think the code looks fine. There's just a typo in the commit message, "donloads" should have said "downloads".

Edit: I'm slightly confused by your statement "as it's not always the date that the version was tagged", though. For example, Git-1.7.11-preview20120710.exe was also tagged on 2012-07-10, but still the download page showed "It was released 3 months ago, on 2012-06-17" before your fix. So I guess the real problem was that most recent Git for Windows releases were not uploaded last, and not on the date they were tagged / built. However, that's just a matter of wording in your commit message, the fix itself seems to be correct. Thank you!

@bry4n
Owner

@sschuberth, I just deployed the fix to git-scm.com few mins ago. The download page showed "It was released 3 months ago, on 2012-07-10."

@carlosmn

I guess I really should tell my editor to start spell-checking automatically.

@sschuberth "tagged" refers to the git version, which is what the site knows about. Before this, it would always show when Junio ran e.g. git tag rather than when msysgit released, as it couldn't tell git and msysgit appart. Even with my couple of fixes, the site is still only partially aware of the difference between them.

Long-term it probably makes sense to read the date from the tag in the msysgit repo, though we still would have to deal with the fact that there is more than one msysgit release for a particular git version, which means that we'd still need to know the tagname <-> filename mapping so it's still going to be a bit fragile, and only really worth it if you decide to change the naming scheme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 25, 2012
  1. @carlosmn

    donloads: show the installer/package release date

    carlosmn authored
    Yet Another Msygit Fix. Store the installer's release date as a
    separate field, as it's not always the date that the version was
    tagged.
    
    This allows us to report the correct release date in the /download/win
    page. Unfortunately the msysgit downloads aren't always uploaded to
    github on the date that the installer has, so we need to parse it to
    get the release date.
This page is out of date. Refresh to see the latest.
View
3  app/models/download.rb
@@ -2,11 +2,12 @@
# t.string :filename
# t.string :platform
# t.references :version
+# t.timestamp :release_date
# t.timestamps
class Download < ActiveRecord::Base
belongs_to :version
def self.latest_for(platform)
- includes(:version).where('platform=?', platform).order('versions.vorder DESC').order('downloads.filename DESC').first
+ includes(:version).where('platform=?', platform).order('versions.vorder DESC').order('downloads.release_date DESC').first
end
end
View
2  app/views/downloads/downloading.html.haml
@@ -11,7 +11,7 @@
%div.callout.downloading
%h3 Your download is starting...
- %p=raw "You are downloading version <strong>#{@download.version.name}</strong> of Git for the <strong>#{@platform.capitalize}</strong> platform. This is the most recent <a href='#{@project_url}'>maintained build</a> for this platform. It was released <strong>#{time_ago_in_words @download.version.committed} ago</strong>, on #{@download.version.committed.strftime("%Y-%m-%d")}."
+ %p=raw "You are downloading version <strong>#{@download.version.name}</strong> of Git for the <strong>#{@platform.capitalize}</strong> platform. This is the most recent <a href='#{@project_url}'>maintained build</a> for this platform. It was released <strong>#{time_ago_in_words @download.release_date} ago</strong>, on #{@download.release_date.strftime("%Y-%m-%d")}."
%p=raw "<strong>If your download hasn't started, <a href=\"#{@download.url}\">click here to download manually</a>.</strong>"
View
17 db/migrate/20120925124736_add_release_date_to_downloads.rb
@@ -0,0 +1,17 @@
+class AddReleaseDateToDownloads < ActiveRecord::Migration
+ def change
+ add_column :downloads, :release_date, :timestamp
+
+ Download.all.each do |d|
+ time = d.version.committed # best guess
+
+ if d.platform == 'windows' # for Windows, take it from the filename
+ d.filename =~ /Git-(.*?)-(.*?)(\d{4})(\d{2})(\d{2})\.exe/
+ time = Time.utc($3, $4, $5)
+ end
+
+ d.release_date = time
+ d.save
+ end
+ end
+end
View
3  db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120423150252) do
+ActiveRecord::Schema.define(:version => 20120925124736) do
create_table "books", :force => true do |t|
t.string "code"
@@ -64,6 +64,7 @@
t.integer "version_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.datetime "release_date"
end
create_table "related_items", :force => true do |t|
View
4 lib/tasks/downloads.rake
@@ -5,7 +5,7 @@ task :downloads => :environment do
# find latest windows version
win_downloads = Octokit.downloads("msysgit/git")
win_downloads.each do |down|
- if m = /^Git-(.*?)-(.*).exe/.match(down.name)
+ if m = /^Git-(.*?)-(.*?)(\d{4})(\d{2})(\d{2})\.exe/.match(down.name)
version = m[1]
puts version = version
puts url = down.html_url
@@ -14,6 +14,7 @@ task :downloads => :environment do
d = v.downloads.where(:url => url).first_or_create
d.filename = down.name
d.platform = 'windows'
+ d.release_date = Time.utc(m[3], m[4], m[5])
d.save
end
end
@@ -31,6 +32,7 @@ task :downloads => :environment do
d = v.downloads.where(:url => url).first_or_create
d.filename = down.name
d.platform = 'mac'
+ d.release_date = down.created_at
d.save
end
end
Something went wrong with that request. Please try again.