Skip to content
This repository has been archived by the owner on Sep 6, 2022. It is now read-only.

Commit

Permalink
Specifically handle situation where there's nothing to commit but we …
Browse files Browse the repository at this point in the history
…tried anyway (#952)

* Specify exactly what files should be added to a commit
- Fixes #847
- WIP

* Specifically handle situation where there's nothing to commit but we tried anyway

* Delete cloudbuild.yaml

* Delete quickstart.sh
  • Loading branch information
taquitos committed Jun 1, 2018
1 parent f9c4510 commit ec09872
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/features/build_runner/build_runner.rb
Expand Up @@ -403,7 +403,7 @@ def prepare_build_object(trigger:)
private

def save_build_status_locally!
# Create or update the local build file in the config directory
# Create local build file in the config directory
Services.build_service.add_build!(
project: project,
build: current_build
Expand Down
4 changes: 2 additions & 2 deletions app/services/project_service.rb
Expand Up @@ -103,8 +103,8 @@ def delete_project!(project: nil)
end

# Not sure if this must be here or not, but we can open a discussion on this.
def commit_repo_changes!(message: nil, file_to_commit: nil)
Services.configuration_git_repo.commit_changes!(commit_message: message, file_to_commit: file_to_commit)
def commit_repo_changes!(message: nil, files_to_commit: [])
Services.configuration_git_repo.commit_changes!(commit_message: message, files_to_commit: files_to_commit)
end

def push_configuration_repo_changes!
Expand Down
22 changes: 18 additions & 4 deletions app/shared/models/git_repo.rb
Expand Up @@ -197,6 +197,17 @@ def handle_exception(ex, console_message: nil, exception_context: {})
details: user_unfriendly_message
)

# Sometimes a repo is told to do something like commit when nothing is added to the change set
# It's weird, and indicative of a race condition somewhere, so let's log it and move on
elsif user_unfriendly_message.include?("Your branch is up to date with")
priority = Notification::PRIORITIES[:warn]
notification_service.create_notification!(
priority: priority,
name: "Up to date repo error",
message: "Unable to perform action, the repo is already up to date #{git_config.git_url}",
details: user_unfriendly_message
)

# Merge conflict, maybe somebody force-pushed something?
elsif user_unfriendly_message.include?("Merge conflict")
priority = Notification::PRIORITIES[:urgent]
Expand Down Expand Up @@ -527,17 +538,20 @@ def reset_hard!(use_global_git_mutex: true)
end

# This method commits and pushes all changes
# if `file_to_commit` is `nil`, all files will be added
# if `files_to_commit` is empty or nil, all files will be added
# TODO: this method isn't actually tested yet
def commit_changes!(commit_message: nil, push_after_commit: true, file_to_commit: nil, repo_auth: self.repo_auth)
def commit_changes!(commit_message: nil, push_after_commit: true, files_to_commit: [], repo_auth: self.repo_auth)
git_action_with_queue do
logger.debug("Starting commit_changes! #{git_config.git_url} for #{repo_auth.username}")
raise "file_to_commit not yet implemented" if file_to_commit
commit_message ||= "Automatic commit by fastlane.ci"

setup_author(full_name: repo_auth.full_name, username: repo_auth.username)

git.add(all: true) # TODO: for now we only add all files
if files_to_commit.nil? || files_to_commit.empty?
git.add(all: true)
else
git.add(files_to_commit)
end
changed = git.status.changed
added = git.status.added
deleted = git.status.deleted
Expand Down
1 change: 1 addition & 0 deletions app/shared/models/notification.rb
Expand Up @@ -7,6 +7,7 @@ class Notification
#
# @return [Hash]
PRIORITIES = {
warn: "warn",
urgent: "urgent",
normal: "normal",
success: "success"
Expand Down

0 comments on commit ec09872

Please sign in to comment.