Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@ #586 | support git minimum version for multi language #588

Merged
merged 2 commits into from
Jan 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions lib/teracy-dev/location/git_synch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,7 @@ class GitSynch < Synch
def initialize
super

current_git_version = `git --version`.gsub("git version", "").strip

required_git_version = '>= 2.20'
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this constraint as I suspect that:

  • with git versions that support LANG env settings (>=2.19.1?), ENV['LANG'] setting below should get git to output in English.
  • with git versions that do not support LANG env settings (< 2.19.1?), ENV['LANG'] does not take any effect and git will always output in English.

With that behavior, we can remove the required_git_version constraint.

Copy link
Member

Choose a reason for hiding this comment

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

my current locale is Vietnamese and with git 2.16.0 => the output is always in English

macbook-pro:homebrew-core hoatle$ git --version
git version 2.16.0
macbook-pro:homebrew-core hoatle$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
macbook-pro:homebrew-core hoatle$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   Formula/git.rb

no changes added to commit (use "git add" and/or "git commit -a")
macbook-pro:homebrew-core hoatle$ LANGUAGE= LANG=en_US.UTF-8 git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   Formula/git.rb

no changes added to commit (use "git add" and/or "git commit -a")
macbook-pro:homebrew-core hoatle$ LANGUAGE= LANG=vi_VN.UTF-8 git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

  modified:   Formula/git.rb

no changes added to commit (use "git add" and/or "git commit -a")

Copy link
Member

Choose a reason for hiding this comment

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

my current locale is Vietnamese and with git 2.20.1 => the output is by default in Vietnamese, and LANG env var settings can be used to force in other languages (English in our case).

macbook-pro:homebrew-core hoatle$ git --version
git version 2.20.1
macbook-pro:homebrew-core hoatle$ git status
Trên nhánh master
Nhánh của bạn đã cập nhật với “origin/master”.

không có gì để chuyển giao, thư mục làm việc sạch sẽ
macbook-pro:homebrew-core hoatle$ LANGUAGE= LANG=en_US.UTF-8 git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Copy link
Contributor Author

@datphan datphan Jan 9, 2019

Choose a reason for hiding this comment

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

with git versions that do not support LANG env settings (< 2.19.1?), ENV['LANG'] does not take any effect and git will always output in English.

sure it is always output in the language its located (not will always output in English), so we should suggest user to upgrade git version above 2.19.1 to take effect (will always output in English) right?

Copy link
Member

Choose a reason for hiding this comment

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

I've rechecked by installing git 2.11.1 from sources with gettext (to enable locale)

$ pwd
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core
$ git show de207300210813de108f7248490068faf253ca7d:Formula/git.rb > git-2.11.rb

And replace git.rb with git-2.11.rb to install git $ brew install git --with-gettext

after that, let's see:

$ git status
Trên nhánh master
Nhánh của bạn đã cập nhật với “origin/master”.
Các thay đổi chưa được đặt lên bệ phóng để chuyển giao:
  (dùng "git add <tập-tin>…" để cập nhật những gì sẽ chuyển giao)
  (dùng "git checkout -- <tập-tin>…" để loại bỏ các thay đổi trong thư mục làm việc)

	đã sửa:        Formula/git.rb

không có thay đổi nào được thêm vào để chuyển giao (dùng "git add" và/hoặc "git commit -a")
$ LANG=en_US.UTF-8 git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   Formula/git.rb

no changes added to commit (use "git add" and/or "git commit -a")

so I can conclude that LANG env var setting should work with many old git versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not work with my machine, LANG does not take effect under ver 2.19.1:

With version 2.11.1:

Dats-MacBook-Pro:k8s-dev datphan$ git --version
git version 2.11.1
Dats-MacBook-Pro:k8s-dev datphan$ git status
On branch develop
nothing to commit, working tree clean
Dats-MacBook-Pro:k8s-dev datphan$ LANG=vi_VN.UTF-8 git status
On branch develop
nothing to commit, working tree clean
Dats-MacBook-Pro:k8s-dev datphan$ LANG=ko_KR.UTF-8 git status
On branch develop
nothing to commit, working tree clean

With version 2.19.1:

Dats-MacBook-Pro:k8s-dev datphan$ brew switch git 2.19.1
...
Dats-MacBook-Pro:k8s-dev datphan$ git --version
git version 2.19.1
Dats-MacBook-Pro:k8s-dev datphan$ git status
On branch develop
nothing to commit, working tree clean
Dats-MacBook-Pro:k8s-dev datphan$ LANG=vi_VN.UTF-8 git status
Tr^en nh'anh develop
nothing to commit, working tree clean
Dats-MacBook-Pro:k8s-dev datphan$ LANG=ko_KR.UTF-8 git status
현재 브랜치 develop
커밋할 사항 없음, 작업 폴더 깨끗함
Dats-MacBook-Pro:k8s-dev datphan$ 

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hoavt pls help me confirm if this works on your machine, thanks


ENV['LANG'] = 'en_US.UTF-8'

ENV['LANGUAGE'] = ''

if !TeracyDev::Util.require_version_valid? current_git_version, required_git_version
@logger.warn("Your current git version (#{current_git_version}) does not meet the required version (#{required_git_version}), please upgrade it to run properly.")
end
ENV['LANGUAGE'] = 'en_US'
end

def sync(location_conf, sync_existing)
Expand Down