Synchronizing code repositories
- Keep the source code synchronized.
- Extract dependency information between your own and third-party modules.
In this system we will call:
- hosts the servers that store source code. For example github.com and gitlab.com
- orgs the first level of repository grouping, it can refer to both an organization or a user.
- repos each of the repositories (within a host and org)
- modules the modules that a repository depends on (probably registered in
npm
) - syncro the synchronization process for each of the repositories in the repos table. It has the following steps:
- download, clone or pull the source code
- repo parse, checks the
package.json
file looking for modules and versions, updating therepo_modules
table (also updatesrepos_vault
which contains the information of the synchronized repositories;repos
is the table of the repositories of interest) - npm update, downloads the information from
npm
and updates themodules
table - auto add, adds to the
repos_vault
table the repositories that have been seen when checking the modules, correspond to the registered orgs and were not previously listed.
Have installed
- Latest LTS version of Node.js
- Latest LTS version of PostgreSQL
- GIT
- Have the PATH to be able to use them.
First you need to create the application configuration file local-config.yaml
.
To do this you can copy the example-local-config.yaml
file and modify the configuration.
server:
port: 3000
base-url: /gitvillance
db: # Parameters to connect to the database when the system is running
description: base de prueba
host: localhost
port: 5432
database: gitvillance_db
schema: gitvillance
user: gitvillance_admin
password: cambiar_esta_clave
install:
dump:
drop-his: false
db: # Parameters for creating the database during installation (manual process)
owner: gitvillance_owner
client-setup:
lang: en # interface language
devel:
delay: 0
log:
db:
on-demand: true
gitvillance:
local-repo: ../local-repo-gitvillance # where the source code will be stored
github-token: github_pat_readonly-token # token that allows listing repositories, can be obtained at https://github.com/settings/personal-access-tokens
Downloading, compiling and creating the initial database
> git clone https://github.com/codenautas/gitvillance
> npm ci
> npm start -- --dump-db
> psql < local-create-db.sql
> psql < local-create-schema.sql
Starting
> npm start
For installation on a server, the service or cron must be scheduled.
In the manual update
menu option you will find the two processes that check the external repositories.
repository sync
is in charge of doinggit clone
orgit pull
, then parsing thepackage.json
and finally fetching information fromnpmjs.org
(for example, what is the latest published version).repo list
checks the repositories of the user and the organizations to which they have access to find new repositories. In order for these new repositories to enter the nextrespository sync
they must have theguard
column set totrue
.