<commit_before># -*- encoding: utf-8 -*-
################################################################################
# git.rake - Special tasks for the management of Git operations
# Time-stamp: <Lun 2014-08-18 21:22 svarrette>
#
# Copyright (c) 2014 <NAME> <<EMAIL>>
#               http://varrette.gforge.uni.lu
################################################################################

require 'falkorlib'
require 'falkorlib/tasks'
require 'falkorlib/git'

#.....................
namespace :git do

    include FalkorLib::Common
    git_root_dir = FalkorLib::Git.rootdir
    remotes = FalkorLib::Git.remotes
    #ap remotes


    ###########   git:fetch   ###########
    #desc "Fetch the latest changes on remotes"
    task :fetch do |t|
        info t.comment
        FalkorLib::Git.fetch()
    end # task fetch

    [ 'up', 'push' ].each do |op|

        description = case op
                      when 'up';   "Update your local copy of the repository from GIT server"
                      when 'push'; "Push your modifications onto the remote branches"
                      end
        ###########  git:{up,push}  ###########
        #desc "#{description}"
        task op.to_sym do |t|
			info description # t.comment
            if remotes.empty? || ! remotes.include?( 'origin' )
                warn "No git remote configured... Exiting #{t}"
                next
            end
            cmd = ( op == 'up') ? 'pull' : op
            branch   = FalkorLib::Git.branch?
            if FalkorLib::Git.list_branch.include? "remotes/origin/#{branch}"
                status = run %{
                      git #{cmd} origin
                }
                if (status.to_i != 0)
                    warn("The command '#{cmd}' failed with exit status #{status.to_i}")
                    warn("This may be due to the fact that you're not connected to the internet")
                    really_continue?('no')
                end
            else
                warn "The current branch '#{branch} is not currently tracked on the remote 'origin'."
                warn "=> exiting"
                next
            end
        end
    end

    unless FalkorLib.config.git[:submodules].empty?
        #.....................
        namespace :submodules do
            ###########   init   ###########
            desc "Initialize the Git subtrees defined in FalkorLib.config.git[:submodules]"
            task :init do |t|
                info t.full_comment
                FalkorLib::Git.submodule_init(git_root_dir)
            end # task submodules:init


        end # namespace submodules
    end

    if File.exists?("#{git_root_dir}/.gitmodules")
        #.....................
        namespace :submodules do

            ########### git:submodules:update ###########
            #desc "Update the git submodules from '#{git_root_dir}'"
            task :update do |t|
                info t.comment
                FalkorLib::Git.submodule_update( git_root_dir )
            end

            ########### git:submodules:upgrade ###########
            desc "Upgrade the git submodules to the latest HEAD commit -- USE WITH CAUTION"
            task :upgrade => [ :update] do |t|
                info t.comment
                FalkorLib::Git.submodule_upgrade( git_root_dir )<commit_msg>correct info<commit_after># -*- encoding: utf-8 -*-
################################################################################
# git.rake - Special tasks for the management of Git operations
# Time-stamp: <Lun 2014-08-18 22:46 svarrette>
#
# Copyright (c) 2014 <NAME> <<EMAIL>>
#               http://varrette.gforge.uni.lu
################################################################################

require 'falkorlib'
require 'falkorlib/tasks'
require 'falkorlib/git'

#.....................
namespace :git do

    include FalkorLib::Common
    git_root_dir = FalkorLib::Git.rootdir
    remotes = FalkorLib::Git.remotes
    #ap remotes


    ###########   git:fetch   ###########
    #desc "Fetch the latest changes on remotes"
    task :fetch do |t|
        info "Fetch the latest changes on remotes" # t.comment
        FalkorLib::Git.fetch()
    end # task fetch

    [ 'up', 'push' ].each do |op|

        description = case op
                      when 'up';   "Update your local copy of the repository from GIT server"
                      when 'push'; "Push your modifications onto the remote branches"
                      end
        ###########  git:{up,push}  ###########
        #desc "#{description}"
        task op.to_sym do |t|
			info description # t.comment
            if remotes.empty? || ! remotes.include?( 'origin' )
                warn "No git remote configured... Exiting #{t}"
                next
            end
            cmd = ( op == 'up') ? 'pull' : op
            branch   = FalkorLib::Git.branch?
            if FalkorLib::Git.list_branch.include? "remotes/origin/#{branch}"
                status = run %{
                      git #{cmd} origin
                }
                if (status.to_i != 0)
                    warn("The command '#{cmd}' failed with exit status #{status.to_i}")
                    warn("This may be due to the fact that you're not connected to the internet")
                    really_continue?('no')
                end
            else
                warn "The current branch '#{branch} is not currently tracked on the remote 'origin'."
                warn "=> exiting"
                next
            end
        end
    end

    unless FalkorLib.config.git[:submodules].empty?
        #.....................
        namespace :submodules do
            ###########   init   ###########
            desc "Initialize the Git subtrees defined in FalkorLib.config.git[:submodules]"
            task :init do |t|
                info t.full_comment
                FalkorLib::Git.submodule_init(git_root_dir)
            end # task submodules:init


        end # namespace submodules
    end

    if File.exists?("#{git_root_dir}/.gitmodules")
        #.....................
        namespace :submodules do

            ########### git:submodules:update ###########
            #desc "Update the git submodules from '#{git_root_dir}'"
            task :update do |t|
                info "Update the git submodules from '#{git_root_dir}'"  # t.comment
                FalkorLib::Git.submodule_update( git_root_dir )
            end

            ########### git:submodules:upgrade ###########
            desc "Upgrade the git submodules to the latest HEAD commit -- USE WITH CAUTION"
            task :upgrade => [ :update] do |t|
                info t.comment
                FalkorLib::Git.submodule_upgrade( git_root_dir )
{'fraction_non_alphanumeric': 0.18544914625092798, 'fraction_numerical': 0.005345211581291759, 'mean_word_length': 1.7708761826408885, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3717019', 'n_tokens_mistral': 1860, 'n_tokens_neox': 1697, 'n_words': 505}