Skip to content

Commit

Permalink
Small fixes on githubrepo
Browse files Browse the repository at this point in the history
- Document how to install rugged --with-ssh in bundler
- Produce an error when using githubrepo without git as an output
- When no repository is defined, this is an error, not a debug message
  • Loading branch information
robertcheramy committed Oct 10, 2024
1 parent 41f59ac commit d7cec3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ bundle config set --local path 'vendor/bundle'
bundle install
```

Note: if you need to install rugged with ssh support, you can tell bundler so with `bundle config build.rugged --with-ssh`. Reinstall rugged with `bundle pristine rugged`

### Run your code
```bash
bundle exec bin/oxidized
Expand Down
8 changes: 7 additions & 1 deletion lib/oxidized/hook/githubrepo.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
require 'rugged'

class GithubRepo < Oxidized::Hook
def validate_cfg!
raise KeyError, 'hook.remote_repo is required' unless cfg.has_key?('remote_repo')
end

def run_hook(ctx)
unless ctx.node.repo
log "Oxidized output is not git, can't push to remote", :error
return
end
repo = Rugged::Repository.new(ctx.node.repo)
creds = credentials(ctx.node)
url = remote_repo(ctx.node)

if url.nil? || url.empty?
log "No repository defined for #{ctx.node.group}/#{ctx.node.name}", :debug
log "No repository defined for #{ctx.node.group}/#{ctx.node.name}", :error
return
end

Expand Down

0 comments on commit d7cec3d

Please sign in to comment.