# Copyright (C) 2020 Chris Liaw # Author: Chris Liaw # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . require_relative 'branch' module GitCli module Push include Branch def push_changes(repos, branch = nil) check_vcs #check_repos raise_if_empty(repos, "Push to repository name cannot be empty", GitCliException) raise_if_false(is_repos_exist?(repos), "Given repository name '#{repos}' is not configured for this workspace", GitCliException) cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "push" cmd << repos if is_empty?(branch) branch = current_branch end cmd << branch cmdln = cmd.join " " log_debug "Push : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end # push_changes alias :push :push_changes def push_changes_with_tags(repos, branch = nil) check_vcs #check_repos raise_if_empty(repos, "Push to repository name cannot be empty", GitCliException) raise_if_false(is_repos_exist?(repos), "Given repository name '#{repos}' is not configured for this workspace", GitCliException) cmd = [] cmd << "cd" cmd << @wsPath cmd << "&&" cmd << @vcs.exe_path cmd << "push" cmd << repos if is_empty?(branch) branch = current_branch end cmd << branch cmd << "--tags" cmdln = cmd.join " " log_debug "Push with tags : #{cmdln}" os_exec(cmdln) do |st, res| [st.success?, res.strip] end end # push_changes_with_tags alias :push_with_tags :push_changes_with_tags alias :push_with_tag :push_changes_with_tags alias :push_changes_with_tag :push_changes_with_tags end end