Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
db2e916a
Commit
db2e916a
authored
6 years ago
by
David Goulet
Browse files
Options
Downloads
Plain Diff
Merge branch 'tor-github/pr/717'
parents
f1890707
7f051602
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changes/feature29532
+4
-0
4 additions, 0 deletions
changes/feature29532
scripts/maint/pre-push.git-hook
+31
-10
31 additions, 10 deletions
scripts/maint/pre-push.git-hook
with
35 additions
and
10 deletions
changes/feature29532
0 → 100644
+
4
−
0
View file @
db2e916a
o Minor features (developer tooling):
- Modify git pre-push hook script to disallow pushing branches other than
master, release-* and maint-* to origin remote. Implements feature
29532.
This diff is collapsed.
Click to expand it.
scripts/maint/pre-push.git-hook
+
31
−
10
View file @
db2e916a
#!/bin/bash
# git pre-push hook script to:
# 1) prevent "fixup!" and "squash!" commit from ending up in master, release-*
# or maint-*
# 2) Disallow pushing branches other than master, release-*
# and maint-* to origin (e.g. gitweb.torproject.org).
#
# To install this script, copy it into .git/hooks/pre-push path in your
# local copy of git repository. Make sure it has permission to execute.
#
# This is git pre-push hook script to prevent "fixup!" and "squash!" commits
# from ending up in upstream branches (master, release-* or maint-*).
#
# The following sample script was used as starting point:
# https://github.com/git/git/blob/master/templates/hooks--pre-push.sample
echo
"Running pre-push hook"
z40
=
0000000000000000000000000000000000000000
CUR_BRANCH
=
$(
git rev-parse
--abbrev-ref
HEAD
)
if
[
"
$CUR_BRANCH
"
!=
"master"
]
&&
[[
$CUR_BRANCH
!=
release-
*
]]
&&
[[
$CUR_BRANCH
!=
maint-
*
]]
then
exit
0
fi
remote
=
"
$1
"
echo
"Running pre-push hook"
ref_is_upstream_branch
()
{
if
[
"
$1
"
==
"refs/heads/master"
]
||
[[
"
$1
"
==
refs/heads/release-
*
]]
||
[[
"
$1
"
==
refs/heads/maint-
*
]]
then
return
1
fi
}
# shellcheck disable=SC2034
while
read
-r
local_ref local_sha remote_ref remote_sha
...
...
@@ -37,6 +44,20 @@ do
range
=
"
$remote_sha
..
$local_sha
"
fi
if
(
ref_is_upstream_branch
"
$local_ref
"
==
0
||
ref_is_upstream_branch
"
$remote_ref
"
==
0
)
&&
[
"
$local_ref
"
!=
"
$remote_ref
"
]
then
if
[
"
$remote
"
==
"origin"
]
then
echo
>
&2
"Not pushing:
$local_ref
to
$remote_ref
"
echo
>
&2
"If you really want to push this, use --no-verify."
exit
1
else
continue
fi
fi
# Check for fixup! commit
commit
=
$(
git rev-list
-n
1
--grep
'^fixup!'
"
$range
"
)
if
[
-n
"
$commit
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment