From dcbd8316dfd4ff465b044f51c77a4ba4d7c7f0f3 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 5 Sep 2015 01:06:52 +0300 Subject: [PATCH 1/5] Remove chrome_version.h from git chrome_version.h is dynamically generated by bootstrap.py so it shouldn't be in git --- atom/common/chrome_version.h | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 atom/common/chrome_version.h diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h deleted file mode 100644 index 250051683786..000000000000 --- a/atom/common/chrome_version.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (c) 2014 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -// This file is generated by script/bootstrap.py, you should never modify it -// by hand. - -#ifndef ATOM_COMMON_CHROME_VERSION_H_ -#define ATOM_COMMON_CHROME_VERSION_H_ - -#define CHROME_VERSION_STRING "45.0.2454.85" -#define CHROME_VERSION "v" CHROME_VERSION_STRING - -#endif // ATOM_COMMON_CHROME_VERSION_H_ From 41e1555cf4cd223024a38bbe70b2b71a395f102d Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Sat, 5 Sep 2015 01:11:37 +0300 Subject: [PATCH 2/5] Add chrome_version.h to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0c6f4cb79dd0..dc7a879cc8aa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +/atom/common/chrome_version.h /build/ /dist/ /external_binaries/ From ad6e67fdfa8bb5443420d27cf42d80ec317b3e81 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 7 Sep 2015 19:51:28 +0300 Subject: [PATCH 3/5] Revert "Add chrome_version.h to gitignore" This reverts commit 41e1555cf4cd223024a38bbe70b2b71a395f102d. --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index dc7a879cc8aa..0c6f4cb79dd0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .DS_Store -/atom/common/chrome_version.h /build/ /dist/ /external_binaries/ From b521e45ef886bd04adf2860898a8a0f1e5784a55 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 7 Sep 2015 19:51:37 +0300 Subject: [PATCH 4/5] Revert "Remove chrome_version.h from git" This reverts commit dcbd8316dfd4ff465b044f51c77a4ba4d7c7f0f3. --- atom/common/chrome_version.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 atom/common/chrome_version.h diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h new file mode 100644 index 000000000000..250051683786 --- /dev/null +++ b/atom/common/chrome_version.h @@ -0,0 +1,14 @@ +// Copyright (c) 2014 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +// This file is generated by script/bootstrap.py, you should never modify it +// by hand. + +#ifndef ATOM_COMMON_CHROME_VERSION_H_ +#define ATOM_COMMON_CHROME_VERSION_H_ + +#define CHROME_VERSION_STRING "45.0.2454.85" +#define CHROME_VERSION "v" CHROME_VERSION_STRING + +#endif // ATOM_COMMON_CHROME_VERSION_H_ From db3e27ceaab98dd7602f8f619eda8ca7df8a3571 Mon Sep 17 00:00:00 2001 From: Eran Tiktin Date: Mon, 7 Sep 2015 21:55:02 +0300 Subject: [PATCH 5/5] Fix `create_chrome_version_h` in bootstrap.py The code was supposed to compare the content of the existing file with the new content and only replace the file if the content was different, but it had a fatal flow. It opened the existing file with 'w+' or 'wb+' and they both truncate the file, so the compare was always false and we always overwrote the file. The updated code compares the file content ignoring line endings and writes the file only if its different or if it didn't exist. --- script/bootstrap.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/script/bootstrap.py b/script/bootstrap.py index 293d3dc2dd10..d5ad41a61c59 100755 --- a/script/bootstrap.py +++ b/script/bootstrap.py @@ -162,13 +162,16 @@ def create_chrome_version_h(): version = f.read() with open(template_file, 'r') as f: template = f.read() - if sys.platform in ['win32', 'cygwin']: - open_mode = 'wb+' - else: - open_mode = 'w+' - with open(target_file, open_mode) as f: - content = template.replace('{PLACEHOLDER}', version.strip()) - if f.read() != content: + content = template.replace('{PLACEHOLDER}', version.strip()) + + # We update the file only if the content has changed (ignoring line ending + # differences). + should_write = True + if os.path.isfile(target_file): + with open(target_file, 'r') as f: + should_write = f.read().replace('r', '') != content.replace('r', '') + if should_write: + with open(target_file, 'w') as f: f.write(content)