使用git hooks 自动更新spring项目中 js 和css 文件版本号

spring项目中,修改了js文件后,重新部署后, 客户端经常会因为缓存了旧的js文件,导致功能异常。

一般的解决方案,是spring中引入资源处理插件,然后把相关资源文件的连接处理成类似test_xxxxxx.js的文件

本方案,再jsp中引用js时采用  test.js?v222222 ,即js文件名+?+版本号,版本号一般就是文件的修改日期。

源代码使用git管理,添加git的pre-commit hooks,在提交包含js或者css的文件修改时,扫描src目录下的相关文件,有带有文件连接的,

使用新的修改后的版本号替换。

git commit 后,会自动把相关的jsp修改后的文件,也一起提交。

https://gist.github.com/minyoad/b27fb53af3930d0093b94b823f0c2292

PS:

使用的是bash脚本,windows 只在wsl中测试过。

babun 访问gitlab 每次弹出用户名密码

问题:

使用babun自带的git,因为工作项目是放在gitlab上,但是每次git pull,都会弹出询问用户名密码,设置了ssh key也是如此。

解决方案:

http://stackoverflow.com/a/36721316/4377192

Get the GCMW’s latest release, download the zip file (not the installer), extract it’s contents (only .dll and .exe files are needed) to C:\cygwin\usr\libexec\git-core\ for 32-bit Cygwin, or C:\cygwin64\usr\libexec\git-core\ for 64-bit Cygwin. Reference

To tell git to use GCMW, execute: git config --global credential.helper manager

To get GUI prompts for credentials, execute: git config --global credential.modalprompt true

If you want this to be a per-repository setting, remove the --global option.

来源: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/issues/146

下载gcmw的zip包,把里面的EXE,DLL文件都拷贝到babun的git-core 目录下

%Profile%\.babun\cygwin\usr\libexec\git-core\

然后设置

git config –global credential.helper manager

如果只是单项目的,移除–global即可

整合的babun下载:

http://www.odrive.tk/?/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/babun-1.2.0-dist.zip

Windows上使用git的两种方式:msysgit+cygwin和相应中文配置

(一)msysgit,最新版本Git-1.7.0.2-preview20100309

安装包是做的越来越好了, 竟然支持直接修改console的字体了。

image

要在msysgit的bash支持中文:

1.修改msysgit安装目录etc下的inputrc文件,红色为要修改的地方,使终端支持中文输入输出。

# disable/enable 8bit input
set meta-flag on
set input-meta on
set output-meta on
set convert-meta off

2.msysgit 默认使用less显示日志,修正git log乱码:

添加

export LESSCHARTSET=labtin1

到profile文件。

3.ls显示中文,添加

继续阅读

在Dropbox同步git版本库

使用过 Dropbox 的人都知道,其只能设置同步名为 My Dropbox 的文件夹,也就是说你不能随意设置想要同步的文件夹,

今天介绍两个微软自己提供的工具(via Cameos),分别适合于 Windows XP 及 Vista、Win7。

看实例:

1、针对 Windows XP 用户,请使用 junction.exe 工具

首先下载 junction.exe,如果你想让 D 盘下的 Data 文件夹与 Dropbox 连接使用,开始 > 运行 > cmd,输入如下命令

C:>junction d:data "d:My Dropbox"

此时你会发现 Data 文件夹和 My Dropbox 文件夹内容相同,在 Data 的任意操作都会继承到 My Dropbox 里,反之相同。

2、针对 Vista、Win7 用户,请使用系统自带的 mklink 命令

例子相同,首先在开始菜单中右键 “命令提示符”,选中 “以管理员身份运行”,之后输入

C:>mklink /d d:data "E:My Dropbox"

现在只要运行着 Dropbox 客户端,Data 文件夹内的内容就会同步到服务器上。

P.S. 命令行中加引号是由于文件夹名中有空格。

继续阅读