Skip to content

Commit

Permalink
Update changelog requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
michhyun1 committed Nov 25, 2020
1 parent c9cdbbf commit 8c42f45
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .changelog-watchlist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Require changelog if files in these directories change
src/
guides/
libs/voicefocus

# Exceptions (Add an exception by adding a path and prepend with a '!' )
58 changes: 31 additions & 27 deletions integration/js/script/run-test
Original file line number Diff line number Diff line change
Expand Up @@ -50,36 +50,40 @@ echo 'Commits:' $commits
requires_integration_test=false
for commit in $commits
do
commit_files=`git diff-tree --no-commit-id --name-only -r ${commit}`
echo 'Commited files are: ' $commit_files
matches=false
for committed_file in $commit_files
do
while read -r stem
do
if [[ $stem =~ ^#.* ]]
then
continue
elif [[ $stem = "" ]]
then
continue
elif [[ $stem =~ ^!.* ]]
then
stem_string="${stem:1}"
if [[ $committed_file = $stem_string* ]]
then
matches=false
fi
elif [[ $committed_file = $stem* ]]
then
requires_integration_test=true
fi
done < "../../.integration-watchlist"
done
commit_files=`git diff-tree --no-commit-id --name-only -r ${commit}`
echo 'Commited files are: ' $commit_files
matches=false
for committed_file in $commit_files
do
while read -r stem
do
if [[ $stem =~ ^#.* ]]
then
continue
elif [[ $stem = "" ]]
then
continue
elif [[ $stem =~ ^!.* ]]
then
stem_string="${stem:1}"
if [[ $committed_file = $stem_string* ]]
then
matches=false
fi
elif [[ $committed_file = $stem* ]]
then
matches=true
fi
done < "../../.integration-watchlist"
if [[ $matches ]]
then
requires_integration_test=true
fi
done
done

echo 'Requires integ tests:' $requires_integration_test
if [[ !$requires_integration_test ]]
if ![[ $requires_integration_test ]]
then
exit 0
fi
Expand Down
42 changes: 38 additions & 4 deletions script/prebuild
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ def verbose command
puts("--> #{command}") || system(command) || fail("Failed: #{command}")
end

def requires_changelog commits
for commit in commits
commit_files=`git diff-tree --no-commit-id --name-only -r #{commit}`.split("\n")
matches = false
for committed_file in commit_files
File.foreach(".changelog-watchlist") do |stem|
stem = stem.strip
if stem == ''
next
elsif stem.start_with?('!')
stem_string = stem[1..-1]
if committed_file.start_with?(stem_string)
matches = false
end
elsif committed_file.start_with?(stem)
puts 'There are changes within ' + stem
matches = true
end
end
if matches
return true
end
end
end
puts 'Does not contain any changes in the changelog watchlist'
return false
end

Dir.chdir(File.expand_path(File.join(File.dirname(__FILE__), '..')))
base = File.read('.base-branch').strip
commits = `git rev-list #{base}..`.strip.split("\n")
Expand All @@ -14,10 +42,16 @@ if commits.size == 0
exit 0
end

changelog = `git diff #{base}.. CHANGELOG.md`.strip
if changelog.length == 0
STDERR.puts "No CHANGELOG.md entries since #{base}."
exit 1
if requires_changelog(commits)
changelog = `git diff #{base}.. CHANGELOG.md`.strip
if changelog.length == 0
STDERR.puts "FAIL: Requires CHANGELOG, but no CHANGELOG.md entries found since #{base}."
exit 1
else
puts "OK: Changelog changes found"
end
else
puts "OK: No Changelog required"
end

# Pull in package fixes automatically.
Expand Down

0 comments on commit 8c42f45

Please sign in to comment.