def commit_in_valid_branch?
      # If two refs are entirely different commit histories, the API responds
      # with a 404. Rescue Octokit::NotFound in this case.
      begin
        default_compare = @client.compare @repo[:full_name],
          @repo[:default_branch], @commit[:sha]
      rescue Octokit::NotFound
        default_compare = nil
      end

      # The compare status should be "identical" or "behind" if the commit is in
      # the default branch
      if default_compare.nil? ||
        !(%w(identical behind).include?(default_compare[:status]))

        # If the commit is not in the default branch, check the gh-pages branch
        begin
          gh_pages_compare = @client.compare @repo[:full_name], "gh-pages",
            @commit[:sha]
        rescue Octokit::NotFound
          gh_pages_compare = nil
        end
        return false if !gh_pages_compare
        return false if !%w(identical behind).include? gh_pages_compare [:status]
      end

      true
    end
def commit_in_valid_branch?
      # If two refs are entirely different commit histories, the API responds
      # with a 404. Rescue Octokit::NotFound in this case.
      begin
        default_compare = @client.compare @repo[:full_name],
          @repo[:default_branch], @commit[:sha]
      rescue Octokit::NotFound
        default_compare = nil
      end

      # The compare status should be "identical" or "behind" if the commit is in
      # the default branch
      if default_compare.nil? ||
        !(%w(identical behind).include?(default_compare[:status]))

        # If the commit is not in the default branch, check the gh-pages branch
        begin
          gh_pages_compare = @client.compare @repo[:full_name], "gh-pages",
            @commit[:sha]
        rescue Octokit::NotFound
          gh_pages_compare = nil
        end
        return false if !gh_pages_compare
        return false if !%w(identical behind).include? gh_pages_compare [:status]
      end

      true
    end
Checks whether the commit is in a valid branch. A valid branch is defined
 as either the default branch of the repository, or the gh-pages branch.

 @return [Boolean]