summaryrefslogtreecommitdiffstats
path: root/docs/guides/onap-developer/how-to-use-docs/update-review.rst
blob: eb4228da737d289b2b8906e578a26e685417cdab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.. This work is licensed under a Creative Commons Attribution 4.0 International License.

.. _updates-and-review:

Updates and Review
==================

**NOTE: THIS SECTION IS UNDER HEAVY DEVELOPMENT USE WITH CAUTION**

Most project owners will need only to concern themselves with their own
project documentation. However, documentation team members and certain
project owners will need to edit and test multiple documentation repositories.
Fortunately, this is possible using git submodules.

Git submodules
--------------

Git submodules are working copies of an upstream repository which you
can clone inside your own project repositories. The documentation team
uses them, for example, to keep up-to-date clones of each contributing
project's :code:`docs` directory, found within the project repositories.

For example:

::

   doc
    +
    |
    + docs
        +
        |
        + submodules
               +
               |
               + ...
               |
               + cli.git
               |    +
               |    |
               |    + ...
               |    |
               |    + docs
               |    |
               |    + ...
               |
               + appc.git
               |    +
               |    |
               |    + ...
               |    |
               |    + docs
               |    |
               |    + ...
               |
               + ...


When the doc team needs to build the master documentation, all the
submodules are first updated before the build.

Setting up Git Submodules as a Doc Team Member
----------------------------------------------

Look `here <https://git-scm.com/book/en/v2/Git-Tools-Submodules>`_ for a
complete discussion of how to work with git submodules in any git
project. In this section, we'll focus on how to work with project submodules with
respect to the documentation.

Doc team members must frequently update submodules to contribute grammar
and spelling fixes, for example. The following describes the
best-practice for doing so.

First, set up your environment according the :ref:`directions for building the entire documentation tree <building-all-documentation>`
and make sure you can build the documentation locally.

Next, we'll need to checkout a branch for each submodule.  Although you
would rarely want to work on the master branch of a project repository
when writing code, we'll stick to the master branch for documentation.
That said, some project leaders might prefer you work with a specific
branch. If so, you'll need to visit each submodule directory to checkout
specific branches. Here, we'll check out the master branch of each submodule:

.. code:: bash

   git submodule foreach 'git checkout master'

You might find that changes upstream have occurred since you cloned the
submodules. To pull in the latest changes:

.. code:: bash

   git submodule foreach 'git pull'

Finally, for every submodule, you'll have to tell git-review how to find
Gerrit. 

.. code:: bash

   cd doc # Make sure we're in the top level doc repo directory
   git submodule foreach 'REPO=$(echo $path | sed "s/docs\/submodules\///") ; git remote add gerrit ssh://<LFID>@gerrit.onap.org:29418/$REPO'
   
Or, if you prefer to do only one at a time:

.. code:: bash

   git remote add gerrit ssh://<LFID>@gerrit.onap.org:29418/repopath/repo.git

Requesting Reviews
------------------

The benefit of working with submodules in this way is that now you can
make changes, do commits, and request reviews within the submodule
directory just as if you had cloned the repository in its own directory.

So, you commit as normal, with :code:`git commit -s`, and review as
normal with :code:`git review`.
>&buffer->ring_mutex, NULL); assert(pthread_rc == 0); pthread_rc = pthread_cond_init(&buffer->ring_cv, NULL); assert(pthread_rc == 0); /***************************************************************************/ /* Allocate the ring buffer itself. */ /***************************************************************************/ buffer->ring = malloc(size * sizeof(void *)); assert(buffer->ring != NULL); /***************************************************************************/ /* Initialize the ring as empty. */ /***************************************************************************/ buffer->next_write = 0; buffer->next_read = 0; buffer->size = size; EVEL_EXIT(); } /**************************************************************************//** * Read an element from a ring_buffer. * * Reads an element from the ring_buffer, advancing the next-read position. * Operation is synchronized and therefore MT-safe. Blocks if no data is * available. * * @param buffer Pointer to the ring-buffer to be read. * * @returns Pointer to the element read from the buffer. ******************************************************************************/ void * ring_buffer_read(ring_buffer * buffer) { void *msg = NULL; EVEL_DEBUG("RBR: Ring buffer read"); pthread_mutex_lock(&buffer->ring_mutex); while (1) { EVEL_DEBUG("RBR: got lock. NR=%d NW=%d", buffer->next_read, buffer->next_write); if(buffer->next_read != buffer->next_write) { EVEL_DEBUG("RBR: buffer has item available"); msg = (buffer->ring)[buffer->next_read]; buffer->ring[buffer->next_read] = NULL; buffer->next_read = (buffer->next_read + 1) % buffer->size; EVEL_DEBUG("RBR: next read location is %d", buffer->next_read); pthread_mutex_unlock(&buffer->ring_mutex); break; } else { EVEL_DEBUG("RBR: Waiting for condition variable"); pthread_cond_wait(&buffer->ring_cv, &buffer->ring_mutex); EVEL_DEBUG("RBR: Condition variable wait completed"); } } EVEL_DEBUG("RBR: Ring buffer read returning data at %lp", msg); return msg; } /**************************************************************************//** * Write an element into a ring_buffer. * * Writes an element into the ring_buffer, advancing the next-write position. * Operation is synchronized and therefore MT-safe. Fails if the buffer is * full without blocking. * * @param buffer Pointer to the ring-buffer to be written. * @param msg Pointer to data to be stored in the ring_buffer. * * @returns Number of items written. * @retval 1 The data was written successfully. * @retval 0 The ring_buffer was full so no data written. ******************************************************************************/ int ring_buffer_write(ring_buffer * buffer, void * msg) { int item_count = 0; int items_written = 0; EVEL_DEBUG("RBW: Ring Buffer Write message at %lp", msg); pthread_mutex_lock(&buffer->ring_mutex); EVEL_DEBUG("RBW: got lock. NR=%d NW=%d SZ=%d", buffer->next_read, buffer->next_write, buffer->size); item_count = (buffer->next_write - buffer->next_read) % buffer->size; if (item_count < 0) { item_count += buffer->size; } if (item_count < buffer->size - 1) { EVEL_DEBUG("RBW: %d items in buffer", item_count); buffer->ring[buffer->next_write] = msg; buffer->next_write = (buffer->next_write + 1) % buffer->size; EVEL_DEBUG("RBW: next write location is %d", buffer->next_write); items_written = 1; } else { EVEL_ERROR("RBW: ring buffer full - unable to write event"); } pthread_mutex_unlock(&buffer->ring_mutex); EVEL_DEBUG("RBW: released lock"); pthread_cond_signal(&buffer->ring_cv); return items_written; } /**************************************************************************//** * Tests whether there is data in the ring_buffer. * * Tests whether there is currently data in the ring_buffer without blocking. * * @param buffer Pointer to the ring-buffer to be tested. * * @returns Whether there is data in the ring_buffer. * @retval 0 There isn't any data in the ring_buffer. * @retval 1 There is data in the ring_buffer. ******************************************************************************/ int ring_buffer_is_empty(ring_buffer * buffer) { int is_empty = 0; EVEL_DEBUG("RBE: Ring empty check"); pthread_mutex_lock(&buffer->ring_mutex); is_empty = (buffer->next_read == buffer->next_write); pthread_mutex_unlock(&buffer->ring_mutex); EVEL_DEBUG("RBE: Ring state= %d", is_empty); return is_empty; }