is there a way to get full path of repository from an svn object?
when i use .path or .pathRepository method i get only relative path of the file
To get the the full uri to a file, use:
SvnInfoEventArgs info;
client.GetInfo(workingCopyPath, out info);
Console.WriteLine(info.Uri);
The repository root:
Console.WriteLine(info.RepositoryRoot);
SvnClient has a method GetRepositoryRoot which gives you the repository root URL. You can then combine this with the relative path of the file you get from .pathRepository.
Related
By using CodeIgniter 4 framework, I've developed RESTful api and there I need to access file (.json and .txt) to get content. But not able to access php inbuilt function file_get_contents().
For more details, pls check attached screenshot API_curl_file_get_content_error.PNG
And test.txt file is also accessible with same file path. For more details pls check screenshot Input-txt-file-content.png
NOTE : 1) test.txt file and respective directories have full permission.
2) Development environment :
<---->Apache/2.4.47 (Win64) OpenSSL/1.1.1k PHP/8.1.2
<---->Database client version: libmysql - mysqlnd 8.1.2
<---->PHP version: 8.1.2
<---->CodeIgniter 4
Product.php (index method)
<?php
namespace App\Controllers;
use CodeIgniter\RESTful\ResourceController;
class Product extends ResourceController
{
use \CodeIgniter\API\ResponseTrait;
public function index()
{
helper("filesystem");
ini_set('max_execution_time', 300);
$data['msg'] = "Product Index wizard";
$data['status'] = 200;
$file_path = base_url() . '/assets/data/test.txt'; // Read JSON
$json = file_get_contents($file_path, true);
$json_data = json_decode($json, true);
return $this->respond($data);
}
}
Explanation:
Remember that "http://localhost:8085/" most likely points to the document root of the project, which is usually the /public path. So, unless the "assets" folder resides in the /public path, file_get_contents("http://localhost:8085/assets/data/test.txt"); will fail to find the requested server resource.
Solution:
Since your file resource (test.txt) is on the local filesystem,
Instead of:
file_get_contents("http://localhost:8085/assets/data/test.txt");
Use this:
constant ROOTPATH
The path to the project root directory. Just above APPPATH.
file_get_contents(ROOTPATH . "assets/data/test.txt");
Addendum:
I believe you also forgot to add the $json_data output to the returned $data variable in the Product::index resource controller method.
I have a sling JCR resource tree, there is resource folder named test and file named testFile inside. testFile have own structure(subnodes/files) inside, I want copy all of them(with subnodes)
/root
|_test
|_testFile
For server test I want to make copy N-times of this file. Any idea how to do it using ResourceResolver ?
I need to have as below:
/root
|_test
|_testFile
|_testFile1
...
|_testFileN
You can write your own utility that does that and use the copy() method of the ResourceResolver, see the docs https://sling.apache.org/apidocs/sling11/org/apache/sling/api/resource/ResourceResolver.html#copy-java.lang.String-java.lang.String-
Is there any way to see the current target SHA of a GitHub repository submodule via Octokit[.net] (without cloning it locally)?
I've been able to track down all the submodules by retrieving the .gitmodules file from the "parent" repo, but that file doesn't maintain where the submodule is pointing with in that submodule repo.
Prior attempts
After finding someone getting this information by indexing into a commit by the submodule path using LibGit2Sharp, I gave that a similar try in Octokit.
var submodulePathContents = await repositoriesClient.Content.GetAllContents(parentRepoId, "path/to/submodule");
While stepping through this code in the debugger, I see this in Locals/Autos, so it definitely knew I was pointing it to a submodule path.
System.Collections.Generic.IReadOnlyList.this[int].get Name:
mono-tools Path: path/to/submodule Type:Submodule
Octokit.RepositoryContent
Unfortunately, when I get the actual content from that list, submodulePathContents[0].Content is just null.
The GitHub web interface definitely surfaces this information when you navigate to a submodule's parent directory, so it makes me think I've just tried the wrong approach.
Is there some other magic way in the Octokit APIs that I've missed to get this submodule target hash?
TL;DR
As described in the question, if you get the contents at the submodule path found in .gitmodules, you will get a piece of content of type "Submodule". This has null content.
If, however, you get the contents of the parent directory for that same submodule path, you will get a piece of content of type "File", with the path of your submodule (e.g., path/to/submodule above). This files hash is the target SHA on the submodule's own repository.
Details
To get the SHA of a submodule, you need to get the contents of its parent directory and then index to the file representing the submodule. While going directly to the path gets you something of type "Submodule", getting the parent contents will get you bunch of "File" type things (and "Dir", if you have sibling subdirectories there). Oddly, this parent content list excludes the "Submodule" type you get when you point directly at the submodule path.
In the example above, just go one level up in the path.
var submodulePathContents = await repositoriesClient.Content.GetAllContents(parentRepoId, "path/to"); // no longer "path/to/submodule"
From there, grab the content item with the path you wanted in the first place (e.g., "path/to/submodule"), which will have a Sha field containing the submodule's target SHA on the submodule repository.
using System.Linq;
…
var submoduleTargetSha = submodulePathContents.First(content => content.Path == submodulePath).Sha;
Here's an example entry from the monodevelop repo's primary submodule directory.
Name: mono-tools Path: main/external/mono-tools Type:File Octokit.RepositoryContent
Content null string
DownloadUrl null System.Uri
EncodedContent null string
Encoding null string
GitUrl {https://api.github.com/repos/mono/mono-tools/git/trees/d858f5f27fa8b10d734ccce7ffba631b995093e5} System.Uri
HtmlUrl {https://github.com/mono/mono-tools/tree/d858f5f27fa8b10d734ccce7ffba631b995093e5} System.Uri
Name "mono-tools" string
Path "main/external/mono-tools" string
Sha "d858f5f27fa8b10d734ccce7ffba631b995093e5" string
Size 0 int
SubmoduleGitUrl null System.Uri
Target null string
Type File Octokit.ContentType
Url {https://api.github.com/repos/mono/monodevelop/contents/main/external/mono-tools?ref=master} System.Uri
And that hash lines up with the web UI.
I need to get the path of the file inside the private folder.
On my local machine I was able to get it by using the path "../../../../../", however, when I deployed to meteor server using meteor deploy, it doesn't work anymore. Also I tried to log the current directory using process.cwd() and got the following, which is different from the structure I got on my local machine:
/meteor/containers/3906c248-566e-61b7-4637-6fb724a33c16/bundle/programs/server
The directory logged from my local machine gives:
/Users/machineName/Documents/projectName/.meteor/local/build/programs/server
Note: I am using this path to setup https://www.npmjs.com/package/apn
You can use assets/app/ as the relative path. While this may not make sense on the first look Meteor re-arranges your /private directory to map to assets/app from the /programs/server directory. This is both in development and production.
Basically assume that private/ maps to assets/app/.
Call Assets.absoluteFilePath(assetPath) on one of the assets in the private folder, then chop of the name of the asset file from the string you get back, e.g., assuming you have a file called test.txt in the private folder:
var aFile = 'test.txt';// test.txt is in private folder
var aFilePath = Assets.absoluteFilePath(aFile);
var aFolder = aFilePath.substr(0, aFilePath.length - aFile.length);
console.log(aFolder);
https://docs.meteor.com/api/assets.html#Assets-absoluteFilePath
The MSDN documentation for this element says "The path that points to the configuration file. This attribute is required if the configuration source is a file." Ok that's fairly obvious.
I tried just setting it to filePath="enterpriselibrary.config". The file exists in the root of my web app. But when I try to log an exception I get "The configuration file enterpriselibrary.config could not be found." Same thing if I use a relative path "~/enterpriselibrary.config".
So what's the story with this file path, does it have to be a hard path (C:
...\MyApp\enterpriselibrary.config)? Is there some documentation that I'm missing?
This is a known bug in EL 5.0: http://entlib.codeplex.com/workitem/26760
The bug is fixed in EL 5.0 Optional Update 1. There is also a workaround on that bug page (code below). I've used the workaround successfully.
workaround:
code:
[Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationElementType(typeof(FileConfigurationSourceElement))]
class FileConfigurationSource : Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource
{
public FileConfigurationSource(string configurationFilepath)
: base(configurationFilepath)
{
}
}
class FileConfigurationSourceElement : Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSourceElement
{
public override Microsoft.Practices.EnterpriseLibrary.Common.Configuration.IConfigurationSource CreateSource()
{
string configurationFilepath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, this.FilePath);
return new FileConfigurationSource(configurationFilepath);
}
}
config:
<add name="sourceName" type="YourNamespase.FileConfigurationSource, YourAssembly" filePath ="fileName"/>
The filePath can be relative or absolute. If you specify a relative path then the path is considered relative to the AppDomain.CurrentDomain.BaseDirectory directory. As you discovered you cannot use a root-relative path (~/enterpriselibrary.config).
I'm not sure why your config file is not found; the root of your web application should be the BaseDirectory.
To debug you can check that:
File.Exists(
Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"enterpriselibrary.config"))
returns true. If it does then Enterprise Library should be able to find the file specified.