File indexing completed on 2024-04-28 17:06:40

0001 #!/bin/bash
0002 
0003 # When you do a merge from the stable branch to the master branch,
0004 # you may see a lot of conflicts and changes in localization-enabled files,
0005 # such as in 'po' dir and .desktop, .appdata.xml files.
0006 # This happens since the branches have separate localization injection streams.
0007 # The script helps to restore these files to the state before the merge,
0008 # with the exception to .appdata.xml that often contains version changes.
0009 
0010 
0011 files_with_status()
0012 {
0013     git status -s | grep '^'"$1" | awk '{ print $2; }'
0014 }
0015 
0016 with_translations()
0017 {
0018     grep -P '(^po/)|(^app/.*\.desktop)'
0019 }
0020 
0021 restore_files()
0022 {
0023     while read f; do
0024         git restore --source=HEAD --staged --worktree "$f"
0025     done
0026 }
0027 
0028 
0029 files_with_status '' | with_translations | restore_files