Browse Source

[enh] add script which add 42 headers and clean the repo for delivery.

Moul 2 years ago
parent
commit
9e4dedcdef
1 changed files with 60 additions and 0 deletions
  1. 60 0
      deliver.sh

+ 60 - 0
deliver.sh

@@ -0,0 +1,60 @@
+#!/bin/zsh
+
+makefile_header="# **************************************************************************** #
+#                                                                              #
+#                                                         :::      ::::::::    #
+#    Makefile                                           :+:      :+:    :+:    #
+#                                                     +:+ +:+         +:+      #
+#    By: mazimi <mazimi@student.42.fr>              +#+  +:+       +#+         #
+#                                                 +#+#+#+#+#+   +#+            #
+#    Created: 2017/03/04 15:35:21 by mazimi            #+#    #+#              #
+#    Updated: 2017/03/04 15:35:21 by mazimi           ###   ########.fr        #
+#                                                                              #
+# **************************************************************************** #\n"       
+
+c_header="/* ************************************************************************** */
+/*                                                                            */
+/*                                                        :::      ::::::::   */
+/*   file.c                                             :+:      :+:    :+:   */
+/*                                                    +:+ +:+         +:+     */
+/*   By: mazimi <mazimi@student.42.fr>              +#+  +:+       +#+        */
+/*                                                +#+#+#+#+#+   +#+           */
+/*   Created: 2017/03/04 15:35:21 by mazimi            #+#    #+#             */
+/*   Updated: 2017/03/04 15:35:21 by mazimi           ###   ########.fr       */
+/*                                                                            */
+/* ************************************************************************** */\n" 
+
+# Add 42 headers on top of source files
+add_42_headers() {
+    for file in "src"/*; do
+        add_42_header "$file"
+    done
+    add_42_header "Makefile"
+    git st
+    git diff
+    git add src Makefile
+    git commit -m "[mod] add 42 headers on top of files."
+}
+
+add_42_header() {
+    src_file=$1
+    tmp="/tmp/42_header"
+    if [ $src_file = "Makefile" ]; then
+        echo $makefile_header > $tmp
+    else
+        echo $c_header > $tmp
+    fi
+    cat $src_file >> $tmp
+    mv $tmp $src_file
+}
+
+clean_repository() {
+    make fclean
+    git rm -rf doc non_use_src leaks.sh deliver.sh
+    rm -f toto
+    git commit -m "[mod] remove non used elements."
+}
+
+git checkout -b deliver
+add_42_headers
+clean_repository