3-way git merge driver for PO files and development bootstrapping script (the start of it anyways)
This commit is contained in:
parent
d1971b6d2b
commit
2ac3633f69
2 changed files with 53 additions and 0 deletions
9
dev_tools/bootstrap_development_environment.sh
Executable file
9
dev_tools/bootstrap_development_environment.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Set up 3 way PO file merging, which we need for non-mainline branches
|
||||
cp scripts/git-merge-po /usr/local/bin
|
||||
chmod +x /usr/local/bin/git-merge-po
|
||||
cat git-config-git-merge-po >> ../.git/config
|
||||
cat git-attributes-git-merge-po >> ../.gitattributes
|
||||
|
||||
|
44
dev_tools/scripts/git-merge-po
Normal file
44
dev_tools/scripts/git-merge-po
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# https://gist.github.com/mezis/1605647
|
||||
# by Julien Letessier (mezis)
|
||||
#
|
||||
# Custom Git merge driver - merges PO files using msgcat(1)
|
||||
#
|
||||
# - Install gettext
|
||||
#
|
||||
# - Place this script in your PATH
|
||||
#
|
||||
# - Add this to your .git/config :
|
||||
#
|
||||
# [merge "pofile"]
|
||||
# name = Gettext merge driver
|
||||
# driver = git merge-po %O %A %B
|
||||
#
|
||||
# - Add this to .gitattributes :
|
||||
#
|
||||
# *.po merge=pofile
|
||||
# *.pot merge=pofile
|
||||
#
|
||||
# - When merging branches, conflicts in PO files will be maked with "#-#-#-#"
|
||||
#
|
||||
O=$1
|
||||
A=$2
|
||||
B=$3
|
||||
|
||||
# Extract the PO header from the current branch (top of file until first empty line)
|
||||
header=$(mktemp /tmp/merge-po.XXXX)
|
||||
sed -e '/^$/q' < $A > $header
|
||||
|
||||
# Merge files, then repair header
|
||||
temp=$(mktemp /tmp/merge-po.XXXX)
|
||||
msgcat -o $temp $A $B
|
||||
msgcat --use-first -o $A $header $temp
|
||||
|
||||
# Clean up
|
||||
rm $header $temp
|
||||
|
||||
# Check for conflicts
|
||||
conflicts=$(grep -c "#-#" $A)
|
||||
test $conflicts -gt 0 && exit 1
|
||||
exit 0
|
Loading…
Add table
Add a link
Reference in a new issue