Bladeren bron

feat(import): First import

Signed-off-by: Jeremy MAURO <jeremy.mauro@gmail.com>
Jeremy MAURO 2 jaren geleden
bovenliggende
commit
84cb1e4554
5 gewijzigde bestanden met toevoegingen van 287 en 0 verwijderingen
  1. 14 0
      config.yaml
  2. 68 0
      dotfiles/git-templates/hooks/jira_check_lib.sh
  3. 70 0
      dotfiles/git-templates/hooks/prepare-commit-msg
  4. 1 0
      dotfiles/terraformrc
  5. 134 0
      dotfiles/vimrc

+ 14 - 0
config.yaml

@@ -8,4 +8,18 @@ config:
   link_on_import: nolink
   longkey: false
 dotfiles:
+  f_terraformrc:
+    src: terraformrc
+    dst: ~/.terraformrc
+  d_git-templates:
+    src: git-templates
+    dst: ~/.git-templates
+  f_vimrc:
+    src: vimrc
+    dst: ~/.vimrc
 profiles:
+  Thinkpad-vhdx:
+    dotfiles:
+    - f_terraformrc
+    - d_git-templates
+    - f_vimrc

+ 68 - 0
dotfiles/git-templates/hooks/jira_check_lib.sh

@@ -0,0 +1,68 @@
+#!/bin/bash
+
+function get_sed () {
+  OS=$(uname  -s)
+  if [ "${OS}" == "Linux" ]; then
+    SED=$(command -v sed)
+  else
+    SED=$(command -v gsed)
+  fi
+  if [ -z "${SED}" ]; then
+    echo ">> GNU 'sed' was not found on the system."
+    echo ">> Please install it"
+    exit 1
+  fi
+  echo "${SED}"
+}
+
+function not_include_ticket () {
+  set -o pipefail
+  if $(cat "$*" | grep -q "^JIRA: "); then
+    return 1
+  fi
+  return 0
+}
+
+function get_branch_name () {
+    echo "$(git branch --show-current)"
+}
+
+# Function to extract the ticket number:
+# Ex: AVXSRE-12324-toto -> AVXSRE-1234
+#     AVXSRE-12134/titi -> AVXSRE-1234
+function clean_branch_name () {
+  echo "$1" | grep -E -o '[A-Z][A-Z0-9]+-[0-9]+'
+}
+
+function add_jira_ref () {
+    # hook arguments
+    COMMIT_MSG_FILE=$1
+    # Possible values are none (git commit), message (git commit -m <msg>), template, merge, squash, or commit
+    COMMIT_SOURCE=$2
+
+    SED="$(get_sed)"
+    BRANCH="$(get_branch_name)"
+    CLEAN_BRANCH="$(clean_branch_name $BRANCH)"
+
+    # check branch name isn’t empty (typical e.g. during rebase)
+    if not_include_ticket "${COMMIT_MSG_FILE}" && [ -n "${CLEAN_BRANCH}" ]; then
+      # check that this is a "message": if a -m or -F option was given
+      if [ "${COMMIT_SOURCE}" == "message" ]; then
+        echo >> "${COMMIT_MSG_FILE}"
+        echo "JIRA: ${CLEAN_BRANCH}" >> "${COMMIT_MSG_FILE}"
+        return 0
+      fi
+
+      # check that this is a "commit"
+      if [ -z "${COMMIT_SOURCE}" ]; then
+        ${SED} -i "1s@^@\n\nJIRA: ${CLEAN_BRANCH}@" "${COMMIT_MSG_FILE}"
+        return 0
+      fi
+
+      # check that this is an "amend"
+      if [ "${COMMIT_SOURCE}" == "commit" ]; then
+        ${SED} -i "2s@^@\n\nJIRA: ${CLEAN_BRANCH}\n@" "${COMMIT_MSG_FILE}"
+        return 0
+      fi
+    fi
+}

+ 70 - 0
dotfiles/git-templates/hooks/prepare-commit-msg

@@ -0,0 +1,70 @@
+#!/usr/bin/env bash
+# Description:  Git hook to check the JIRA reference in the commit message
+# Usage:        Copy this file on your hooksPath with the name "commit-msg"
+# Ref:          https://aviatrix.atlassian.net/l/c/ARC3NMy1#Git-client-hook-for-automatic-Jira-ref-insertion
+
+set -e
+
+[ -z "${GITHOOK_DEBUG}" ] || set -x
+
+# hook arguments
+COMMIT_MSG_FILE=$1
+# Possible values are none (git commit), message (git commit -m <msg>), template, merge, squash, or commit
+COMMIT_SOURCE=$2
+
+BRANCH=$(git branch --show-current)
+
+function get_sed () {
+  OS=$(uname  -s)
+  if [ "${OS}" == "Linux" ]; then
+    SED=$(command -v sed)
+  else
+    SED=$(command -v gsed)
+  fi
+  if [ -z "${SED}" ]; then
+    echo ">> GNU 'sed' was not found on the system."
+    echo ">> Please install it"
+    exit 1
+  fi
+  echo "${SED}"
+}
+
+function not_include_ticket () {
+  set -o pipefail
+  if $(cat "$*" | grep -q "^JIRA: "); then
+    return 1
+  fi
+  return 0
+}
+
+# Function to extract the ticket number:
+# Ex: AVXSRE-12324-toto -> AVXSRE-1234
+#     AVXSRE-12134/titi -> AVXSRE-1234
+function get_branch_name () {
+  echo "$*" | ${SED} -e 's@\([[:alpha:]]\+\).*-\([[:digit:]]\+\).*@\1-\2@g'
+}
+
+SED="$(get_sed)"
+BRANCH="$(get_branch_name $(git branch --show-current))"
+
+# check branch name isn’t empty (typical e.g. during rebase)
+if not_include_ticket "${COMMIT_MSG_FILE}" && [ -n "${BRANCH}" ]; then
+  # check that this is a "message": if a -m or -F option was given
+  if [ "${COMMIT_SOURCE}" == "message" ]; then
+    echo >> ${COMMIT_MSG_FILE}
+    echo "JIRA: ${BRANCH}" >> ${COMMIT_MSG_FILE}
+    exit 0
+  fi
+
+  # check that this is a "commit"
+  if [ -z "${COMMIT_SOURCE}" ]; then
+    ${SED} -i "1s@^@\n\nJIRA: ${BRANCH}@" ${COMMIT_MSG_FILE}
+    exit 0
+  fi
+
+  # check that this is an "amend"
+  if [ "${COMMIT_SOURCE}" == "commit" ]; then
+    ${SED} -i "2s@^@\n\nJIRA: ${BRANCH}\n@" ${COMMIT_MSG_FILE}
+    exit 0
+  fi
+fi

+ 1 - 0
dotfiles/terraformrc

@@ -0,0 +1 @@
+plugin_cache_dir = "/tmp/.terraform.d/plugin-cache"

+ 134 - 0
dotfiles/vimrc

@@ -0,0 +1,134 @@
+" -----------------------------------------------------------------------------
+" Status line
+" -----------------------------------------------------------------------------
+
+" Heavily inspired by: https://github.com/junegunn/dotfiles/blob/master/vimrc
+function! s:statusline_expr()
+  let mod = "%{&modified ? '[+] ' : !&modifiable ? '[x] ' : ''}"
+  let ro  = "%{&readonly ? '[RO] ' : ''}"
+  let ft  = "%{len(&filetype) ? '['.&filetype.'] ' : ''}"
+  let fug = "%{exists('g:loaded_fugitive') ? fugitive#statusline() : ''}"
+  let sep = ' %= '
+  let pos = ' %-12(%l : %c%V%) '
+  let pct = ' %P'
+
+  return '[%n] %f %<'.mod.ro.ft.fug.sep.pos.'%*'.pct
+endfunction
+
+let &statusline = s:statusline_expr()
+
+" Use a line cursor within insert mode and a block cursor everywhere else.
+"
+" Using iTerm2? Go-to preferences / profile / colors and disable the smart bar
+" cursor color. Then pick a cursor and highlight color that matches your theme.
+" That will ensure your cursor is always visible within insert mode.
+"
+" Reference chart of values:
+"   Ps = 0  -> blinking block.
+"   Ps = 1  -> blinking block (default).
+"   Ps = 2  -> steady block.
+"   Ps = 3  -> blinking underline.
+"   Ps = 4  -> steady underline.
+"   Ps = 5  -> blinking bar (xterm).
+"   Ps = 6  -> steady bar (xterm).
+let &t_SI = "\e[6 q"
+let &t_EI = "\e[2 q"
+
+set rtp+=/usr/share/vim/addons/plugin/powerline.vim
+set t_Co=256
+
+syntax on
+
+set autoindent
+set smartindent
+set autoread
+set backspace=indent,eol,start
+set backupdir=/tmp//,.
+set clipboard=unnamedplus,unnamed
+set complete+=kspell
+set completeopt=menuone,longest
+set cursorline
+set directory=/tmp//,.
+set encoding=utf-8
+set expandtab
+set smarttab
+set formatoptions=tcqrn1
+set hidden
+set hlsearch
+set ignorecase
+set incsearch
+set laststatus=2
+set matchpairs+=<:> " Use % to jump between pairs
+set mmp=5000
+set modelines=2
+set mouse=a
+set nocompatible
+set noerrorbells visualbell t_vb=
+set noshiftround
+set nospell
+set nostartofline
+set number relativenumber
+set regexpengine=1
+set ruler
+set scrolloff=0
+set shiftwidth=2
+set showcmd
+set showmatch
+set shortmess+=c
+set showmode
+set smartcase
+set softtabstop=2
+set spelllang=en_us
+set splitbelow
+set splitright
+set tabstop=2
+
+color desert
+
+" WSL yank support
+" Ref: https://superuser.com/questions/1291425/windows-subsystem-linux-make-vim-use-the-clipboard
+let s:clip = '/mnt/c/Windows/System32/clip.exe'  " change this path according to your mount point
+if executable(s:clip)
+    augroup WSLYank
+        autocmd!
+        autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif
+    augroup END
+endif
+
+" Plug-vim
+let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
+if empty(glob(data_dir . '/autoload/plug.vim'))
+  silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
+  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
+endif
+
+call plug#begin()
+" Syntastic is a syntax checking plugin for Vim
+Plug 'vim-syntastic/syntastic'
+" Fugitive is the premier Vim plugin for Git.
+Plug 'tpope/vim-fugitive'
+" Lean & mean status/tabline for vim that's light as air.
+Plug 'vim-airline/vim-airline'
+Plug 'vim-airline/vim-airline-themes'
+" Sometimes, it's useful to line up text.
+Plug 'https://github.com/godlygeek/tabular'
+" Go plug in
+Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
+"	If you've ever tried using the . command after a plugin map
+Plug 'tpope/vim-repeat'
+" EasyClip is a plugin for Vim which contains a collection of clipboard related functionality
+"Plug 'svermeulen/vim-easyclip'
+" Powerlien for vim
+Plug 'powerline/powerline'
+" Terraform
+Plug 'hashivim/vim-terraform'
+" Comment lines
+Plug 'tpope/vim-commentary'
+" Completion
+Plug 'ervandew/supertab'
+" Markdown TOC
+Plug 'mzlogin/vim-markdown-toc'
+call plug#end()
+
+" Integrate Powerline fonts
+let g:airline_powerline_fonts = 1