You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ja...@apache.org on 2018/07/15 17:54:39 UTC

[couchdb] branch feat/show-git-hash-in-info updated (e1bb5e8 -> 91fad83)

This is an automated email from the ASF dual-hosted git repository.

jan pushed a change to branch feat/show-git-hash-in-info
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


    omit e1bb5e8  Merge branch 'master' into feat/show-git-hash-in-info
    omit c8b0b0a  report git sha on welcome request
     add e928b88  hook up proxy auth handler to chttpd
     add aa73e4e  Views now retain update_seq after compaction.
     add a5858b9  Replace R16B03 with 17.5.3 for PR#1427
     add 0f130cb  Drop Erlang R16 support
     add 4ea7210  config: improve handling of admin-supplied changes
     add 768e9eb  build: ease pattern matching to be less pedantic about RC
     add a82419b  build: release candidate tarball should have -RCx
     add 5c93cb7  Use couch_util:trim for greater erlang compatibility
     add 3c3546c  string:trim() compat for couch_util:trim()
     add fa3c812  bump deps
     add 1703998  raise timeouts in attachment tests
     add 215f49b  wait for db deletion before db re-creation. Closes #1197
     add dacb658  Clarify bad index creation error messages
     add dd3a6b4  validate bind address by @wyc
     add 8e5caaf  demote notice to debug logs by @wyc
     new 91fad83  Report git sha on welcome request

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (e1bb5e8)
            \
             N -- N -- N   refs/heads/feat/show-git-hash-in-info (91fad83)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                                     |  1 -
 Jenkinsfile                                     |  4 +--
 Makefile                                        | 15 ++++++---
 Makefile.win                                    |  8 ++---
 build-aux/couchdb-build-release.sh              |  6 +++-
 rebar.config.script                             |  6 ++--
 rel/overlay/etc/default.ini                     |  5 +++
 src/chttpd/src/chttpd_auth.erl                  |  4 +++
 src/chttpd/src/chttpd_misc.erl                  | 10 ++++--
 src/couch/rebar.config.script                   |  2 +-
 src/couch/src/couch_httpd_misc_handlers.erl     |  2 +-
 src/couch/src/couch_util.erl                    | 40 ++++++++++++++++++++---
 src/couch/test/couchdb_attachments_tests.erl    |  6 ++--
 src/couch_mrview/src/couch_mrview_compactor.erl |  2 ++
 src/mango/src/mango_error.erl                   |  4 +--
 src/setup/src/setup.erl                         | 43 ++++++++++++++++---------
 test/javascript/tests/users_db.js               |  7 ++++
 17 files changed, 119 insertions(+), 46 deletions(-)


[couchdb] 01/01: Report git sha on welcome request

Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jan pushed a commit to branch feat/show-git-hash-in-info
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 91fad8317740eee4208d39b786adea4f9f99a5ee
Author: Jan Lehnardt <ja...@apache.org>
AuthorDate: Fri Jul 13 14:26:43 2018 +0200

    Report git sha on welcome request
    
    Closes #1309
---
 Makefile                                | 3 ++-
 Makefile.win                            | 6 +++---
 build-aux/couchdb-build-release.sh      | 6 +++++-
 src/chttpd/src/chttpd_misc.erl          | 1 +
 src/chttpd/test/chttpd_welcome_test.erl | 2 ++
 src/couch/rebar.config.script           | 8 ++++++++
 src/couch/src/couch_server.erl          | 3 ++-
 7 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 27d9531..fa8f6f2 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@
 include version.mk
 
 REBAR?=$(shell echo `pwd`/bin/rebar)
+COUCHDB_GIT_SHA=$(git_sha)
 IN_RELEASE = $(shell if [ ! -d .git ]; then echo true; fi)
 ifeq ($(IN_RELEASE), true)
 COUCHDB_VERSION = $(vsn_major).$(vsn_minor).$(vsn_patch)
@@ -82,7 +83,7 @@ help:
 .PHONY: couch
 # target: couch - Build CouchDB core, use ERL_OPTS to provide custom compiler's options
 couch: config.erl
-	@COUCHDB_VERSION=$(COUCHDB_VERSION) $(REBAR) compile $(COMPILE_OPTS)
+	@COUCHDB_VERSION=$(COUCHDB_VERSION) COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) $(REBAR) compile $(COMPILE_OPTS)
 	@cp src/couch/priv/couchjs bin/
 
 
diff --git a/Makefile.win b/Makefile.win
index 5a2a73a..7acb835 100644
--- a/Makefile.win
+++ b/Makefile.win
@@ -14,6 +14,7 @@ include version.mk
 
 SHELL=cmd.exe
 REBAR?=$(shell where rebar.cmd)
+COUCHDB_GIT_SHA=$(git_sha)
 IN_RELEASE = $(shell if not exist .git echo true)
 ifeq ($(IN_RELEASE), true)
 COUCHDB_VERSION_SUFFIX=
@@ -26,8 +27,7 @@ endif
 DESTDIR=
 
 # Rebar options
-apps=
-skip_deps=folsom,meck,mochiweb,triq,snappy
+apps=skip_deps=folsom,meck,mochiweb,triq,snappy
 suites=
 tests=
 
@@ -53,7 +53,7 @@ all: couch fauxton docs
 .PHONY: couch
 # target: couch - Build CouchDB core
 couch: config.erl
-	@set COUCHDB_VERSION=$(COUCHDB_VERSION) && $(REBAR) compile
+	@set COUCHDB_VERSION=$(COUCHDB_VERSION) && && set COUCHDB_GIT_SHA=$(COUCHDB_GIT_SHA) && $(REBAR) compile
 	@copy src\couch\priv\couchjs.exe bin
 
 
diff --git a/build-aux/couchdb-build-release.sh b/build-aux/couchdb-build-release.sh
index 4482b71..2d219e5 100755
--- a/build-aux/couchdb-build-release.sh
+++ b/build-aux/couchdb-build-release.sh
@@ -35,8 +35,12 @@ done
 
 cd ..
 
-# create CONTRIBUTORS file
+
 if test -e .git; then
+    # save git sha in version.mk
+    git_sha=`git rev-parse --short HEAD`
+    echo "git_sha=$git_sha" >> $RELDIR/version.mk
+    # create CONTRIBUTORS file
     OS=`uname -s`
     case "$OS" in
     Linux|CYGWIN*) # GNU sed
diff --git a/src/chttpd/src/chttpd_misc.erl b/src/chttpd/src/chttpd_misc.erl
index 95345d4..f4467b6 100644
--- a/src/chttpd/src/chttpd_misc.erl
+++ b/src/chttpd/src/chttpd_misc.erl
@@ -49,6 +49,7 @@ handle_welcome_req(#httpd{method='GET'}=Req, WelcomeMessage) ->
     send_json(Req, {[
         {couchdb, WelcomeMessage},
         {version, list_to_binary(couch_server:get_version())},
+        {git_sha, list_to_binary(couch_server:get_version_suffix())},
         {features, config:features()}
         ] ++ case config:get("vendor") of
         [] ->
diff --git a/src/chttpd/test/chttpd_welcome_test.erl b/src/chttpd/test/chttpd_welcome_test.erl
index af9732f..b737abd 100644
--- a/src/chttpd/test/chttpd_welcome_test.erl
+++ b/src/chttpd/test/chttpd_welcome_test.erl
@@ -60,6 +60,8 @@ should_have_version(Url) ->
         Version = couch_util:get_value(<<"version">>, Json, undefined),
         CouchDB = couch_util:get_value(<<"couchdb">>, Json, undefined),
         Features = couch_util:get_value(<<"features">>, Json, undefined),
+        Sha = couch_util:get_value(<<"git_sha">>, Json, undefined),
+        ?assertNotEqual(Sha, undefined),
         ?assertEqual(<<"Welcome">>, CouchDB),
         RealVersion = list_to_binary(couch_server:get_version()),
         ?assertEqual(RealVersion, Version),
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
index 498ce3a..44e1c07 100644
--- a/src/couch/rebar.config.script
+++ b/src/couch/rebar.config.script
@@ -39,6 +39,13 @@ Version = case os:getenv("COUCHDB_VERSION") of
         string:strip(Version0, right)
 end,
 
+VersionSuffix = case os:getenv("COUCHDB_GIT_SHA") of
+    false ->
+        ""; % release builds won’t get a fallback
+    VersionSuffix0 ->
+        string:strip(VersionSuffix0, right)
+end,
+
 CouchConfig = case filelib:is_file(os:getenv("COUCHDB_CONFIG")) of
     true ->
         {ok, Result} = file:consult(os:getenv("COUCHDB_CONFIG")),
@@ -142,6 +149,7 @@ AddConfig = [
     {port_specs, PortSpecs},
     {erl_opts, PlatformDefines ++ [
         {d, 'COUCHDB_VERSION', Version},
+        {d, 'COUCHDB_VERSION_SUFFIX', VersionSuffix},
         {i, "../"}
     ]},
     {eunit_compile_opts, PlatformDefines}
diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl
index 002f08e..ea42b4c 100644
--- a/src/couch/src/couch_server.erl
+++ b/src/couch/src/couch_server.erl
@@ -15,7 +15,7 @@
 -behaviour(config_listener).
 -vsn(3).
 
--export([open/2,create/2,delete/2,get_version/0,get_version/1,get_uuid/0]).
+-export([open/2,create/2,delete/2,get_version/0,get_version/1,get_version_suffix/0,get_uuid/0]).
 -export([all_databases/0, all_databases/2]).
 -export([init/1, handle_call/3,sup_start_link/0]).
 -export([handle_cast/2,code_change/3,handle_info/2,terminate/2]).
@@ -57,6 +57,7 @@ get_version(short) ->
   [Version|_Rest] = string:tokens(get_version(), "+"),
   Version.
 
+get_version_suffix() -> ?COUCHDB_VERSION_SUFFIX.
 
 get_uuid() ->
     case config:get("couchdb", "uuid", undefined) of