Skip to content

Commit

Permalink
Check Git branch in production mode
Browse files Browse the repository at this point in the history
When the current Git branch isn't the `main` branch, exit the `mono`
executable. This is to ensure that users don't accidentally use an
unmerged and unreviewed branch.

Developers can use the `mono-dev` executable instead.
  • Loading branch information
tombruijn committed Sep 29, 2021
1 parent 616571e commit f70a877
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changesets/check-git-branch-for-mono.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bump: "patch"
---

Check Git branch for mono to prevent accidental usage of mono on an unmerged branch.
10 changes: 10 additions & 0 deletions bin/mono
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ unless git_status.empty?
exit 1
end

current_branch = `git rev-parse --abbrev-ref HEAD`.chomp
unless current_branch == "main"
puts "ERROR: The mono repository is not on the `main` branch. " \
"Please switch to the main branch to ensure you're using a released " \
"version."
puts "Please use the `mono-dev` executable if you want to use uncommitted " \
"changes to _test_ mono itself."
exit 1
end

$LOAD_PATH << File.expand_path(File.join(__dir__, "..", "lib"))

require "mono"
Expand Down

0 comments on commit f70a877

Please sign in to comment.