0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gerritをとりあえず立ち上げて、使うまでの手順 (docker利用)

Last updated at Posted at 2024-09-29

memo

fix the permission error

docker ps
permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/json": dial unix /var/run/docker.sock: connect: permission denied

sudo chmod 666 /var/run/docker.sock

pull docker image

https://hub.docker.com/r/gerritcodereview/gerrit/tags
から使いたいtagをみて

docker pull gerritcodereview/gerrit:3.10.1-ubuntu22
docker run -d -p 8080:8080 -p 29418:29418 gerritcodereview/gerrit

run

docker run -ti -p 8080:8080 -p 29418:29418 gerritcodereview/gerrit

明示タグでの起動

docker run -ti -p 8080:8080 -p 29418:29418 gerritcodereview/gerrit:3.9.6-ubuntu22

dockerの他の操作

dockerの停止

docker stop $(docker ps -q)

docker images (pull済みのimageのlist)

docker images

remove images

docker rmi c4ba92a033df

or

docker rmi gerritcodereview/gerrit:latest

access to the gerrit

ifconfig | grep 192

From another machine (同じマシンならlocalhostでok)

open http://themachine.local:8080

add key to gerrit

cat ~/.ssh/id_rsa.pub

上をブラウザからSettings/SSH Keysに追加

check from the same machine as the browser

gerritを走らせているマシンをubuntu2とする (.ssh/configに追加しておくと良い)

~/.ssh/config
Host gerrit
    HostName themachine.local
    User admin
    Port 29418
    Protocol 2
    IdentityFile ~/.ssh/id_rsa
    ServerAliveInterval 60
ssh gerrit gerrit -h

remove the machine ip's fingerprint from ~/.ssh/known_hosts

create the test

ssh gerrit gerrit create-project --empty-commit test

clone

cd ~/work/gerrit_temp
git clone ssh://gerrit/test 
cd test
scp -O -p gerrit:hooks/commit-msg .git/hooks/
~/work/gerrit_temp/test/.git/commit-msg
#!/bin/sh
# From Gerrit Code Review 3.10.1
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -u

# avoid [[ which is not POSIX sh.
if test "$#" != 1 ; then
  echo "$0 requires an argument."
  exit 1
fi

if test ! -f "$1" ; then
  echo "file does not exist: $1"
  exit 1
fi

# Do not create a change id if requested
case "$(git config --get gerrit.createChangeId)" in
  false)
    exit 0
    ;;
  always)
    ;;
  *)
    # Do not create a change id for squash/fixup commits.
    if head -n1 "$1" | LC_ALL=C grep -q '^[a-z][a-z]*! '; then
      exit 0
    fi
    ;;
esac


if git rev-parse --verify HEAD >/dev/null 2>&1; then
  refhash="$(git rev-parse HEAD)"
else
  refhash="$(git hash-object -t tree /dev/null)"
fi

random=$({ git var GIT_COMMITTER_IDENT ; echo "$refhash" ; cat "$1"; } | git hash-object --stdin)
dest="$1.tmp.${random}"

trap 'rm -f "$dest" "$dest-2"' EXIT

if ! cat "$1" | sed -e '/>8/q' | git stripspace --strip-comments > "${dest}" ; then
   echo "cannot strip comments from $1"
   exit 1
fi

if test ! -s "${dest}" ; then
  echo "file is empty: $1"
  exit 1
fi

reviewurl="$(git config --get gerrit.reviewUrl)"
if test -n "${reviewurl}" ; then
  token="Link"
  value="${reviewurl%/}/id/I$random"
  pattern=".*/id/I[0-9a-f]\{40\}"
else
  token="Change-Id"
  value="I$random"
  pattern=".*"
fi

if git interpret-trailers --parse < "$1" | grep -q "^$token: $pattern$" ; then
  exit 0
fi

# There must be a Signed-off-by trailer for the code below to work. Insert a
# sentinel at the end to make sure there is one.
# Avoid the --in-place option which only appeared in Git 2.8
if ! git interpret-trailers \
         --trailer "Signed-off-by: SENTINEL" < "$1" > "$dest-2" ; then
  echo "cannot insert Signed-off-by sentinel line in $1"
  exit 1
fi

# Make sure the trailer appears before any Signed-off-by trailers by inserting
# it as if it was a Signed-off-by trailer and then use sed to remove the
# Signed-off-by prefix and the Signed-off-by sentinel line.
# Avoid the --in-place option which only appeared in Git 2.8
# Avoid the --where option which only appeared in Git 2.15
if ! git -c trailer.where=before interpret-trailers \
         --trailer "Signed-off-by: $token: $value" < "$dest-2" |
     sed -e "s/^Signed-off-by: \($token: \)/\1/" \
         -e "/^Signed-off-by: SENTINEL/d" > "$dest" ; then
  echo "cannot insert $token line in $1"
  exit 1
fi

if ! mv "${dest}" "$1" ; then
  echo "cannot mv ${dest} to $1"
  exit 1
fi

start

create test_branch

git checkout -b test_branch

add

git add *.py
git commit -m "Add xxx.py and yyy.py"

upload(1)

git add *
git commit --amend
git push origin HEAD:refs/for/master

upload (2)

git checkout master
git pull --ff-only origin master
git checkout test_branch
git rebase -i master
git push origin HEAD:refs/for/master

check the changes

open http://gerrit.local:8080/q/status:open+-is:wip

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?