Skip to content

Commit

Permalink
Merge pull request #211 from vishwanatharondekar/same-name-repo-fix
Browse files Browse the repository at this point in the history
fix: filter by project name when length of projects received is more …
  • Loading branch information
vishwanatharondekar authored Oct 23, 2023
2 parents f3a4b4c + 3277f76 commit cb9f014
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,13 +459,15 @@ function createMergeRequest(options) {
logger.log('\nProject name derived from host :', projectName)
logger.log('\nGetting gitlab project info for :', projectName)
store.set({ sourceRemoteURL: remoteURL })
store.set({ sourceProjectName: projectName })
return gitlab.Projects.search(projectName, {
search_namespaces: true,
membership: true,
})
})
.then(function(project) {
project = project[0]
var sourceProjectName = store.get('sourceProjectName')
project = project.find((innerProject)=>{ return innerProject.path_with_namespace === sourceProjectName})
logger.log('Base project info obtained :', JSON.stringify(project).green)

var defaultBranch = project.default_branch
Expand Down Expand Up @@ -504,13 +506,15 @@ function createMergeRequest(options) {

logger.log('Getting target project information')
store.set({ targetRemoteUrl: targetRemoteUrl })
store.set({ targetProjectName: targetProjectName })
return gitlab.Projects.search(targetProjectName, {
search_namespaces: true,
membership: true,
})
})
.then(function(targetProject) {
targetProject = targetProject[0]
var targetProjectName = store.get('targetProjectName')
targetProject = targetProject.find((project)=>{ return project.path_with_namespace === targetProjectName})
logger.log(
'Target project info obtained :',
JSON.stringify(targetProject).green
Expand Down Expand Up @@ -727,4 +731,4 @@ if (program.args.length < 1) {
program.outputHelp()
}

module.exports = function() {}
module.exports = function() {}

0 comments on commit cb9f014

Please sign in to comment.