-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Azure DevOps mounter #150
base: master
Are you sure you want to change the base?
Azure DevOps mounter #150
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||
require 'glue/mounters/base_mounter' | ||||||
require 'fileutils' | ||||||
|
||||||
class Glue::AzDOMounter < Glue::BaseMounter | ||||||
|
||||||
Glue::Mounters.add self | ||||||
|
||||||
def initialize trigger, options | ||||||
super(trigger) | ||||||
@options = options | ||||||
@name = "AzDO Git" | ||||||
@description = "Pull a repo." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
end | ||||||
|
||||||
def mount target | ||||||
base = @options[:working_dir] | ||||||
|
||||||
Glue.debug "Making base." | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it stay here? |
||||||
FileUtils.mkdir_p base | ||||||
|
||||||
# Grab the path used as git url, excluding PAT. | ||||||
# format of this target must be https://DUMMY:<PAT_TOKEN>@dev.azure.com/<account>/<project>/_git/<repository> | ||||||
protocol, azdo_domain, account, project, repository = target.match(/\A(.*\/\/).*@(.*)\/(.*)\/(.*)\/_git\/(.+?)[\/]{0,1}\z/i).captures | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe get these parameters separately and build the URL? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am thinking on maybe having PATTOKEN as a configuration parameter, as can be useful for something else (working on creating work items on Azure DevOps, like the ones for Jira, Pivotal...) Parameters I extract from the match are for building the folder name used for temporary storage, but the target url should be ````https://dev.azure.com/../../_git/....``` So that way, you can just use the Git Url you can copy/paste from Azure DevOps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh I see. Ok, so just move the PAT to paramter - which could also help in reducting it. |
||||||
|
||||||
path = [azdo_domain, account, project, repository].map{|i| '/'+i}.join | ||||||
working_target = File.expand_path(base + "" + path + "/") | ||||||
|
||||||
Glue.notify "Cleaning directory: #{working_target}" | ||||||
if ! Dir.exists? working_target | ||||||
Glue.notify "#{working_target} is not a directory." | ||||||
FileUtils.mkdir_p working_target | ||||||
else | ||||||
Glue.debug "Removing : #{working_target}" | ||||||
FileUtils.rm_rf working_target | ||||||
FileUtils.mkdir_p working_target | ||||||
end | ||||||
# result = `rm -rf #{working_target}` | ||||||
# puts result | ||||||
Glue.debug "Cloning into: #{working_target}" | ||||||
result = `git clone -q #{target} #{working_target}` | ||||||
# puts result | ||||||
#end | ||||||
return working_target | ||||||
end | ||||||
|
||||||
def supports? target | ||||||
if target.include?("@dev.azure.com/") && target.include?("/_git/") | ||||||
return true | ||||||
else | ||||||
return false | ||||||
end | ||||||
end | ||||||
|
||||||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe think on a more clear name? AzureGitMounter maybe?