2 ###############################################################################
3 # Copyright (c) 2016 Ericsson
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Eclipse Public License v1.0
7 # which accompanies this distribution, and is available at
8 # http://www.eclipse.org/legal/epl-v10.html
9 ###############################################################################
11 # A script that checks every plugin for modifications since last release
12 # and prompt to bump the micro version if necessary.
14 # Usage ./check_plugins_changes.sh [ignoredCommit1,ignoredCommit2,...]
16 # Where ignoredcommit is a 7 characters commit hash which will not be
17 # considered in the diffs (useful for big commits that didn't affect code)
19 # For example ./check_plugins_changes.sh 1325468,1325469
21 IFS
=', ' read -r -a IGNORED_COMMITS
<<< "$1"
23 PREV_RELEASE_VERSION
=$
(git tag
-l |
tail -1 | cut
-c 2-)
24 echo "Baseline version detected: $PREV_RELEASE_VERSION. If this is wrong, stop the script (Ctrl-C)"
25 read -rsp $
'Press any key to continue...\n' -n1 key
27 # Stats for the summary
34 ALL_PLUGIN_PATHS
=($
(dirname $
(dirname $
(find ..
/..
-name "MANIFEST.MF"))))
37 for plugin_path
in "${ALL_PLUGIN_PATHS[@]}"; do
39 commit_summary
=$
(git log
--oneline --max-count=1 -- $plugin_path)
40 commit_id
=$
(echo $commit_summary |
awk '{print $1}')
42 # Check if the commit we are about to consider should be ignored
43 # and choose a better one if that's the case.
44 check_ignored_commit
=1
45 while [ $check_ignored_commit -eq 1 ]; do
46 check_ignored_commit
=0
47 for ignored_commit
in "${IGNORED_COMMITS[@]}"; do
48 if [ "$ignored_commit" = "$commit_id" ]
50 echo Ignoring commit
$commit_id
51 commit_summary
=$
(git log
$commit_id~
1 --oneline --max-count=1 -- "$plugin_path")
52 commit_id
=$
(echo $commit_summary |
awk '{print $1}')
53 echo New commit
: $commit_id
54 check_ignored_commit
=1
59 manifest_diff
=$
(git
diff v
$PREV_RELEASE_VERSION -- $plugin_path/META-INF
/MANIFEST.MF
)
60 is_new_file
=$
(echo "$manifest_diff" |
grep "\-\-\- /dev/null")
62 # We don't need to do anything for a new pluging that wasn't there
63 # before, the initial version is always good
64 if [[ -n "$is_new_file" ]]
66 echo "new plugin $plugin_path"
67 num_new_plugins
=$
((num_new_plugins
+1))
71 old_version
=$
(echo "$manifest_diff" |
grep "\-Bundle-Version" | cut
-c 2-)
72 cur_version
=$
(grep Bundle-Version
"$plugin_path/META-INF/MANIFEST.MF")
74 plugin_diff
=$
(git
diff v
$PREV_RELEASE_VERSION $commit_id -- "$plugin_path")
75 # Is the plugin bump needed? Check if the last commit of the plugin matches the previous release tag
76 # or if there was no difference (aside from the ignored commits)
77 tags_containing
=$
(git tag
--contains $commit_id)
78 if [[ -z "$plugin_diff" ||
($tags_containing == *"$PREV_RELEASE_VERSION"*) ]]
80 echo "no update needed $plugin_path ($cur_version)"
81 num_no_bump_needed
=$
((num_no_bump_needed
+1))
85 # Is the plugin already bumped? Check if versions are different
86 if [[ -n "$old_version" && ("$cur_version" != "$old_version") ]]
88 echo "bumped already $plugin_path ($old_version -> $cur_version)"
89 num_bumped_already
=$
((num_bumped_already
+1))
93 # At this point, we have a potential version bump necessary. We will ask the user to decide what to do.
95 cur_major_minor
=$
(echo $cur_version |
sed -rn 's/Bundle-Version:\s([0-9][0-9]*\.[0-9][0-9]*).*/\1/p')
96 cur_micro
=$
(echo $cur_version |
sed -rn 's/Bundle-Version:\s[0-9][0-9]*\.[0-9][0-9]*\.([0-9][0-9]*).*/\1/p')
99 git
diff v
$PREV_RELEASE_VERSION $commit_id -- "$plugin_path"
100 echo "Might need bump: $plugin_path ($cur_version) ($commit_summary)"
102 read -p "Bump version from $cur_major_minor.$cur_micro to $cur_major_minor.$next_micro? (y/n) " answer
106 * ) echo "yes (y) or no (n).";;
110 if [[ $answer == "Y" ||
$answer == "y" ]]
112 num_bumped
=$
((num_bumped
+1))
113 sed -i -E 's/(Bundle-Version:\s)[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*(.*)/\1'$cur_major_minor.
$next_micro'\2/g' "$plugin_path/META-INF/MANIFEST.MF"
115 num_not_bumped
=$
((num_not_bumped
+1))
119 # Print a little summary of how the plugins were processed
121 echo Total plugins
: ${#ALL_PLUGIN_PATHS[@]}
122 echo New
: $num_new_plugins
123 echo Already bumped
: $num_bumped_already
124 echo Bumped
: $num_bumped
125 echo Not bumped by choice
: $num_not_bumped
126 echo No bump needed
: $num_no_bump_needed
128 num_processed
=$
(($num_new_plugins + $num_bumped_already + $num_bumped + $num_not_bumped + $num_no_bump_needed))
129 if [[ $num_processed -ne ${#ALL_PLUGIN_PATHS[@]} ]]
131 echo "Number of plugins processed mismatch! ($num_processed vs ${#ALL_PLUGIN_PATHS[@]})"
133 echo "All plugins processed."
This page took 0.038906 seconds and 5 git commands to generate.