Skip to content

Commit

Permalink
Merge pull request #336 from remote-jp/enable-to-track-company-commit…
Browse files Browse the repository at this point in the history
…-info-with-git

Enable to track company commit details from each page
  • Loading branch information
yasulab authored Jan 16, 2025
2 parents dc0213e + 2a2f97c commit 0921004
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source 'http://rubygems.org'

gem 'git'
gem 'rake'
gem 'sanitize'

Expand Down
29 changes: 29 additions & 0 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ GEM
remote: http://rubygems.org/
specs:
Ascii85 (2.0.1)
activesupport (8.0.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
afm (0.2.2)
Expand All @@ -10,15 +23,18 @@ GEM
fiber-annotation
io-event (~> 1.6, >= 1.6.5)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
colorator (1.1.0)
concurrent-ruby (1.3.4)
connection_pool (2.5.0)
console (1.29.2)
fiber-annotation
fiber-local (~> 1.1)
json
crass (1.0.6)
csv (3.3.2)
drb (2.2.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
Expand All @@ -32,6 +48,11 @@ GEM
fiber-storage
fiber-storage (1.0.0)
forwardable-extended (2.6.0)
git (2.3.3)
activesupport (>= 5.0)
addressable (~> 2.8)
process_executer (~> 1.1)
rchardet (~> 1.8)
google-protobuf (4.29.2)
bigdecimal
rake (>= 13)
Expand Down Expand Up @@ -87,6 +108,7 @@ GEM
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.4)
mercenary (0.4.0)
minitest (5.25.4)
nokogiri (1.18.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.18.1-x86_64-linux-gnu)
Expand All @@ -99,13 +121,15 @@ GEM
hashery (~> 2.0)
ruby-rc4
ttfunk
process_executer (1.2.0)
public_suffix (6.0.1)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rchardet (1.9.0)
rexml (3.4.0)
rouge (4.5.1)
ruby-rc4 (0.1.5)
Expand All @@ -122,6 +146,7 @@ GEM
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
securerandom (0.4.1)
support-for (1.0.7)
sass (~> 3.3)
terminal-table (3.0.2)
Expand All @@ -130,7 +155,10 @@ GEM
bigdecimal (~> 3.1)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)
webrick (1.9.1)
yell (2.2.2)
zeitwerk (2.7.1)
Expand All @@ -143,6 +171,7 @@ DEPENDENCIES
base64
bigdecimal
csv
git
html-proofer
jekyll
jekyll-include-cache
Expand Down
4 changes: 4 additions & 0 deletions docs/ignore_revs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
c622258109c96c4976c2172c319de7d9adb470d2
55b87a11b90840360f3093eff4eb94b4297fdcdf
412984c2089abfba5ec8788f189acc109d7173dd
29671d3f9e398fc92f5dd3025b95a9ce90cea3b1
12 changes: 10 additions & 2 deletions docs/upsert_data_by_readme.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby

require 'git'
require 'kramdown'
require 'sanitize'

Expand All @@ -20,9 +21,9 @@
# Remove existing files, parse README, and re-generate them
Dir.glob("./#{lang}/_posts/*.md").each { |filename| File.delete(filename) }

git = Git.open(`git rev-parse --show-toplevel`.chomp!)
start_parsing_flag = false
readme.each_with_index do |line, index|

readme.each.with_index(1) do |line, index|
# Operate start-of and end-of parsing table of lines in README.
if start_parsing_flag == false
start_parsing_flag = true if line.start_with? '| ---'
Expand All @@ -34,6 +35,11 @@
next unless line.include? '|'
cells = line.gsub('\|', '&#124;').split '|'

# Fetch latest commit info
latest_commit_id = `git blame ../README.md -L #{index},+1 --porcelain --ignore-revs-file=docs/ignore_revs.txt`.strip.lines[0].split.first
latest_commit_at = git.gcommit(latest_commit_id).author_date.strftime('%Y-%m-%d')
latest_commit_url = 'https://github.com/remote-jp/remote-in-japan/commit/' + latest_commit_id

# Fetch company name and its link from 1st cell
name_and_link = Kramdown::Document.new(cells[1]).root.children[0].children[0]
name = name_and_link.children[0].value.strip
Expand All @@ -59,6 +65,8 @@
description: '#{Sanitize.clean(CGI.unescapeHTML description).strip}'
categories: #{is_full_remote}
link: #{link}
commit_url: #{latest_commit_url}
commit_at: #{latest_commit_at}
---
#{CGI.unescapeHTML description}
Expand Down

0 comments on commit 0921004

Please sign in to comment.