how to fetch git remote url using grgit APIs - git-remote

I need to read .git folder having below git remote url within my groovy script using grgit APIs.
url = git#github.com:***/****.git
Can you please help

I could do as below
import org.ajoberstar.grgit.Grgit
Grgit git = new Grgit()
def gitRoot = project.hasProperty('git.root') ? project.property('git.root') : project.rootProject.projectDir
git = Grgit.open(dir: gitRoot)
System.out.println("git.remote.list().url -->"+git.remote.list().url)

Related

Update environment variable in Postman

I'm using Newman and Postman to test a website.
My Newman command construction looks like:
newman run
"https://api.getpostman.com/collections/{collection_id}?apikey={my_postman_api_key}"
--environment "https://api.getpostman.com/environments/{environment_id}?apikey={my_postman_api_key}"
--export-environment "https://api.getpostman.com/environments/{environment_id}?apikey={my_postman_api_key}"
--insecure
This all works fine but my environment values don't update after the Newman run.
In my request, I use a Pre-request Script to update the value:
var mail = pm.environment.get("mail_randomizer");
pm.environment.set("mail_randomizer", Number(mail) + 1);
After sending this request in Postman, the value for the mail_randomizer variable has gone up by 1 but after running the request using Newman, it doesn't work.
How can I export the environment correctly in Newman?
create
.env : environment variable let's say
url = http://localhost:3000/api
.env.example should be
url =
in your test call :
var local-url = process.env.url;
add in your package json
npm install dotenv

Phalcon Dev Tools - Builder doesn't knows where is the models directory

I'm getting "Builder doesn't knows where is the models directory" error when I run the phalcon all-models command in both Command Line and Phalcon Webtools.
Please let me know what am I missing?
My webtools.config.php content
define('PTOOLS_IP', '216.174.134.2');
define('PTOOLSPATH', '/var/www/html/vendor/phalcon/devtools');
My webtools.php content
use Phalcon\Web\Tools;
require 'webtools.config.php';
require PTOOLSPATH . '/scripts/Phalcon/Web/Tools.php';
Tools::main(PTOOLSPATH, PTOOLS_IP);
My config.ini content
[database]
adapter = Mysql
host = localhost
username = test
password = test
dbname = test
[application]
controllersDir = ../app/controllers/
modelsDir = ../app/models/
viewsDir = ../app/views/
pluginsDir = ../app/plugins/
libraryDir = ../app/library/
cacheDir = ../app/cache/
baseUri = /
[models]
metadata.adapter = "Memory"
I have change the modelsDir from ../app/models/ to /../app/models/ but still not working.
ANSWER FOUND:
Going to project root directory and type the command (instructions)
# phalcon all-models --directory /var/www/html/projec_name
I speficied the --directory which is the Base path on which project will be created.
Thank you colburton for helping me debug this problem. Much appreciated.
Going to project root directory and type the command (instructions)
# phalcon all-models --directory /var/www/html/projec_name
I speficied the --directory which is the Base path on which project will be created.
Thank you colburton for helping me debug this problem. Much appreciated.
In the options array you pass to the builder you need to add 'modelsDir' with the correct path.
On this page you can find a video with the webtools. There is a tab for "Configuration", where you can set them.
It is also located in the config.ini under app/config
I am using Phalcon 3. After generating a project with phalcon console tool I encountered this error.
There is an easy way out to resolve this issue. Change the following settings in app/config/config.ini if you have one.
[application]
controllersDir = app/controllers/
modelsDir = app/models/
viewsDir = app/views/
pluginsDir = app/plugins/
libraryDir = app/library/
cacheDir = ../cache/

it is possible to download GitHub repository to my local computer

hello friends i just started to use GitHub and i just want to know it is possible to download github repository to my local computer through by Using GitHub Api or Api libraries (ie. python library " pygithub3" for Github api)
Using github3.py you can clone all of your repositories (including forks and private repositories) by doing:
import github3
import subprocess
g = github3.login('username', 'password')
for repo in g.iter_repos(type='all'):
subprocess.call(['git', 'clone', repo.clone_url])
If you're looking to clone an arbitrary repository you can do this:
import github3
import subprocess
r = github3.repository('owner', 'repository_name')
subprocess.call(['git', 'clone', repo.clone_url])
pygithub3 has not been actively developed in over a year. I would advise not use it since it is unmaintained and missing a large number of the additions GitHub has made to their API since then.
As illustrated in this Gist, the simplest solution is simply to call git clone.
#!/usr/bin/env python
# Script to clone all the github repos that a user is watching
import requests
import json
import subprocess
# Grab all the URLs of the watched repo
user = 'jharjono'
r = requests.get("http://github.com/api/users/%s/subscriptions" % (user))
repos = json.loads(r.content)
urls = [repo['url'] for repo in repos['repositories']]
# Clone them all
for url in urls:
cmd = 'git clone ' + url
pipe = subprocess.Popen(cmd, shell=True)
pipe.wait()
print "Finished cloning %d watched repos!" % (len(urls))
This gist, which uses pygithub3, will call git clone on the repos it finds:
#!/usr/bin/env python
import pygithub3
gh = None
def gather_clone_urls(organization, no_forks=True):
all_repos = gh.repos.list(user=organization).all()
for repo in all_repos:
# Don't print the urls for repos that are forks.
if no_forks and repo.fork:
continue
yield repo.clone_url
if __name__ == '__main__':
gh = pygithub3.Github()
clone_urls = gather_clone_urls("gittip")
for url in clone_urls:
print url

review board diff not uploading

i am currently attempting to do a diff using review board but keep getting an ambiguous error message:
Error uploading diff
Your review request still exists, but the diff is not attached.
The debug messages do not give much away either, no errors whatsoever....
>>> RBTools 0.4.1
>>> Home = /home/tom
>>> HTTP GETting api/
>>> HTTP GETting http://127.0.0.1/api/info/
>>> Using the new web API
Index: /trunk/0.1/scripts/configure-apache.sh
===================================================================
--- /trunk/0.1/scripts/configure-apache.sh (revision 143)
+++ /trunk/0.1/scripts/configure-apache.sh (working copy)
## -1,5 +1,5 ##
#! /bin/bash
-
+echo hello
cd ..
#SRCHEAD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SRCHEAD=$SRC_HEAD
This is what my ".reviewboardrc" file contains:
REVIEWBOARD_URL = "http://127.0.0.1/"
the repository path is: "https://XXX/svn/infinity/trunk/0.1"
does anyone know where i can start in order to resolve this issue i am seeing?
thanks in advance
The problem you are facing may be that the relative path in the diff file is not correlated with the path of the repository as it is configured in Reviewboard.
Reviewboard, in order to find in the repository the files mentioned in the diff, will concatenate the URLs like this:
URL of the repo as configured in Reviewboard
+
optionally - the Base directory as it appears in the
Reviewboard Upload diff dialog - which can be absolute/complete
but also relative(!)
+
the relative path of the modified file as it appears in the diff file.
All these must be correlated.
Therefore, in your case, if your repository configured URL is:
https://XXX/svn/infinity/trunk/0.1
and your relative path in the diff file is:
/trunk/0.1/scripts/configure-apache.sh
... that will not work because the resulting absolute path of the file in the repo will be incorrect:
https://XXX/svn/infinity/trunk/0.1/trunk/0.1/scripts/configure-apache.sh
Possible solutions would be:
Your URL for SVN should be configured in Reviewboard like this:
https://XXX/svn/infinity
OR
The diff should be created at a lower level in the folders hierarchy - in this case it should be done at ../0.1/ level so that the path in the diff file results in /scripts/configure-apache.sh
HTH!
a workaround is to do a manual svn diff and save to a file and then compare the working copy with the trunk in the web ui

Fetching new revisions after a directory move in SVN

I have a git-svn configuration as follows:
[svn-remote "svn"]
rewriteRoot = http://myproject
url = http://myserver/myproject/trunk/proj
fetch = :refs/remotes/git-svn
My company decided to move the directory trunk to v100 (at revision xxxxx).
After the move, I updated the url attribute but I am no longer able to do a git svn rebase. git-svn chokes with some SVN error (Cannot replace a directory from within).
A fresh checkout fetches only revisions newer than xxxxx.
How can I get all revisions and still have continuous history?
I think we had configured the git-svn sync wrongly. We should have used:
[svn-remote "svn"]
rewriteRoot = http://myproject
url = http://myserver/myproject
fetch = trunk/proj:refs/remotes/git-svn
That is, "trunk/proj" should have been part of the "fetch". If I make a fresh git svn clone with this, I am able to get previous versions as well.