CString CSettingGitCredential::Load(CString key) { CString cmd; if (m_strUrl.IsEmpty()) cmd.Format(L"credential.%s", (LPCTSTR)key); else cmd.Format(L"credential.%s.%s", (LPCTSTR)m_strUrl, (LPCTSTR)key); CAutoConfig config(true); CAutoRepository repo(g_Git.GetGitRepository()); int sel = m_ctrlConfigType.GetCurSel(); if (sel == ConfigType::Local) git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitLocalConfig()), GIT_CONFIG_LEVEL_LOCAL, repo, FALSE); else if (sel == ConfigType::Global) { git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitGlobalConfig()), GIT_CONFIG_LEVEL_GLOBAL, repo, FALSE); git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitGlobalXDGConfig()), GIT_CONFIG_LEVEL_XDG, repo, FALSE); } else if (sel == ConfigType::System) git_config_add_file_ondisk(config, CGit::GetGitPathStringA(g_Git.GetGitSystemConfig()), GIT_CONFIG_LEVEL_SYSTEM, repo, FALSE); CStringA cmdA = CUnicodeUtils::GetUTF8(cmd); CStringA valueA; git_config_entry* entry; if (!git_config_get_entry(&entry, config, cmdA)) valueA = CStringA(entry->value); git_config_entry_free(entry); return CUnicodeUtils::GetUnicode(valueA); }
TEST(commit, tree) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); auto vector = head.getAffectedFiles(); EXPECT_TRUE(std::find(vector.begin(), vector.end(), "file.txt") != vector.end()); EXPECT_TRUE(std::find(vector.begin(), vector.end(), "subfolder/file") != vector.end()); }
TEST(diff, stats) { Repository repo("../test/testrepo"); Diff diff = repo.head().toCommit().getDiff(); ASSERT_EQ(diff.linesDeleted(), 0); ASSERT_EQ(diff.linesAdded(), 2); ASSERT_EQ(diff.filesChanged(), 2); }
int main(int argv, char **argc) { QCoreApplication app(argv, argc); Gittin::Repo repo("."); QString action = app.arguments().size() > 1 ? app.arguments().at(1) : QString(); if (action == QLatin1String("init")) { repo.init(); } else if (action == QLatin1String("status")) { Gittin::RepoStatus status = repo.status(); qDebug()<<"untracked:" << status.untrackedFiles(); qDebug()<<"staged:" << status.stagedFiles(); qDebug()<<"dirty" << status.dirtyFiles(); } else if (action == QLatin1String("show_tags")) { qDebug() << repo.tags(); } else if (action == QLatin1String("check_branch")) { Gittin::Branch branch(&repo, app.arguments().at(2)); qDebug() << branch.exists(); } else if (action == QLatin1String("commit")) { Gittin::Branch branch(&repo, app.arguments().at(2)); qDebug() << branch.head(app.arguments().at(3).toInt()); } else if (action == QLatin1String("hash-object")) { qDebug() << repo.hashObject(app.arguments().at(2)); } return 0; }
Component::Repository* Component::repo(bool ensure) const { if(meta_){ if(not meta_->repo){ std::string path = Component::path(true); Repository* repo = new Repository; try{ repo->open(path); } catch(Git::NoRepoError){ if(ensure) repo->init(path,true); // Do an initial commit else{ delete repo; repo = nullptr; } } meta_->repo = repo; } return meta_->repo; } else { if(ensure){ meta_ = new Meta; return repo(true); } else return nullptr; } }
bool GITHUB_GETLIBLIST::repoURL2listURL( const wxString& aRepoURL, std::string* aFullURLCommand, int aItemCountMax, int aPage ) { // aListURL is e.g. "https://api.github.com/orgs/KiCad/repos" // or "https://api.github.com/users/KiCad/repos" // aRepoURL is e.g. "https://github.com/KiCad" // Github has a default pagination set to 30 items. // but allows up to 100 items max if we add the "?per_page=100" option wxURI repo( aRepoURL ); if( repo.HasServer() && repo.HasPath() ) { // goal: "https://api.github.com/orgs/KiCad" wxString target_url( wxT( "https://api.github.com/orgs" ) ); target_url += repo.GetPath(); target_url += wxT( "/repos" ); // Github has a default pagination set to 30 items. // but allows up to 100 items max. Use this limit target_url += wxString::Format( "?per_page=%d&page=%d", aItemCountMax, aPage ); *aFullURLCommand = target_url.utf8_str(); return true; } return false; }
TEST(commit, parent) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); ASSERT_EQ(head.parentCount(), 1); ASSERT_EQ(head.parent(0).author().name(), "Tim Siebels"); ASSERT_THROW(head.parent(1), GitException); }
void SoundComponentLoader::initialize(const std::string& repository){ m_SndComponentRepository = repository; if(!m_IsInitialized){ if(!fs::exists(repository)){ LOG_ERROR("Cannot open sound component repository"); return; // remain uninitialized } fs::path repo(repository); // Iterate through all files in the directory for(fs::recursive_directory_iterator end, iter(repo); iter != end; ++iter){ if(!fs::is_directory(iter.status()) && !fs::extension(*iter).compare(".so")){ LOG_DEBUG("Found library: " << *iter); loadLibrary(iter->path().string()); } } } m_IsInitialized = true; }
Component& Component::managed(bool yes){ if(not managed()){ if(not yes) STENCILA_THROW(Exception,"It is only possible to turn on component management; use `manage(true)`."); repo(true); } return *this; }
Output::Output(CompilerState& state) : m_state(state) , m_repo(state.m_context, state.m_module) , m_builder(nullptr) , m_stackMapsId(1) , m_currentBlockTerminated(false) { m_argType = pointerType(arrayType(repo().intPtr, state.m_platformDesc.m_contextSize / sizeof(intptr_t))); state.m_function = addFunction( state.m_module, "main", functionType(repo().voidType, m_argType)); llvmAPI->SetFunctionCallConv(state.m_function, LLVMFastCallConv); m_builder = llvmAPI->CreateBuilderInContext(state.m_context); m_prologue = appendBasicBlock("Prologue"); positionToBBEnd(m_prologue); buildGetArg(); }
void InitCommand::exec() { std::cout << "Initializing repository..." << std::endl; boost::filesystem::path repo_path = Repository::is_repository_exists(""); Repository repo(repo_path.string()); repo.init_repository(""); std::cout << "Done" << std::endl; }
void ofPackageManager::addPackageToAddonsMakeFile(std::string path) { ofxGit::repository repo(ofFilePath::join(_cwdPath, path)); auto url = repo.getRemoteUrl(); auto checkout = repo.getCommitHash(); ofLogNotice() << path << url << checkout; addPackageToAddonsMakeFile(ofPackage(path, url, checkout)); }
LValue Output::buildTcgHelperCall(void* func, int num, LValue* param) { LValue params[4 + num]; LValue funcVal = constIntPtr(reinterpret_cast<intptr_t>(func)); funcVal = buildCast(LLVMIntToPtr, funcVal, repo().ref8); params[0] = constInt64(m_stackMapsId); params[1] = constInt32(7); params[2] = funcVal; params[3] = constInt32(num); for (int i = 4; i < num + 4; ++i) { LValue p = param[i - 4]; params[i] = p; } LValue call = buildCall(repo().patchpointInt64Intrinsic(), params, 4 + num); // record the stack map info m_stackMapsId++; return call; }
Component& Component::sync(void) { if(origin().length()){ auto r = repo(); r->download(); r->merge("origin/master","master"); r->upload(); } else STENCILA_THROW(Exception,"Component is not published so can not be synced."); return *this; }
TEST(commit, author) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); Signature author = head.author(); Signature committer = head.committer(); ASSERT_EQ(author.name(), "Tim Siebels"); ASSERT_EQ(author.mail(), "*****@*****.**"); ASSERT_EQ(committer.name(), "Tim Siebels"); ASSERT_EQ(committer.mail(), "*****@*****.**"); }
void ImageRepoTest::testScan() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testScan() begin"); debug(LOG_DEBUG, DEBUG_LOG, 0, "scan directory %s", directory.c_str()); ImageRepo repo("repotest", database, directory); debug(LOG_DEBUG, DEBUG_LOG, 0, "testScan() end"); }
void ImageRepoTest::testSelect() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testSelect() begin"); ImageRepo repo("repotest", database, directory, false); ImageSpec spec; spec.purpose(Exposure::dark); spec.temperature(-47); std::set<ImageEnvelope> resultset = repo.get(spec); debug(LOG_DEBUG, DEBUG_LOG, 0, "found %d darks with temperature -47", resultset.size()); debug(LOG_DEBUG, DEBUG_LOG, 0, "testSelect() end"); }
int GitRev::GetCommit(const CString& refname) { if (g_Git.UsingLibGit2(CGit::GIT_CMD_GET_COMMIT)) { CAutoRepository repo(g_Git.GetGitRepository()); if (!repo) { m_sErr = g_Git.GetLibGit2LastErr(); return -1; } return GetCommit(repo, refname); } CAutoLocker lock(g_Git.m_critGitDllSec); try { g_Git.CheckAndInitDll(); } catch (char* msg) { m_sErr = L"Could not initiate libgit.\nlibgit reports:\n" + CString(msg); return -1; } if(refname.GetLength() >= 8) if (refname.GetLength() >= 8 && wcsncmp(refname, GitRev::GetWorkingCopy(), refname.GetLength()) == 0) { this->m_CommitHash.Empty(); this->m_Subject = L"Working Tree"; m_sErr.Empty(); return 0; } CStringA rev; rev= CUnicodeUtils::GetUTF8(g_Git.FixBranchName(refname)); GIT_HASH sha; try { if (git_get_sha1(rev.GetBuffer(), sha)) { m_sErr = L"Could not get SHA-1 of ref \"" + g_Git.FixBranchName(refname); return -1; } } catch (char * msg) { m_sErr = L"Could not get SHA-1 of ref \"" + g_Git.FixBranchName(refname) + L"\".\nlibgit reports:\n" + CString(msg); return -1; } CGitHash hash(sha); return GetCommitFromHash_withoutLock(hash); }
void Output::buildTcgIndirectPatch(void) { PatchDesc desc = { PatchType::TcgIndirect }; LValue call = buildCall(repo().patchpointVoidIntrinsic(), constInt64(m_stackMapsId), constInt32(m_state.m_platformDesc.m_tcgSize), constNull(repo().ref8), constInt32(0)); llvmAPI->SetInstructionCallConv(call, LLVMAnyRegCallConv); buildUnreachable(m_builder); // record the stack map info auto result = m_state.m_patchMap.insert(std::make_pair(m_stackMapsId++, desc)); EMASSERT(result.second == true); m_currentBlockTerminated = true; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); LocalConfigRepository repo(0, 0); bool success = true; QDir testsDir(TESTS_DIR); QFileInfoList fileInfos = testsDir.entryInfoList(QDir::Files, QDir::Name); if (argc > 1 && strstr(argv[1], "-v") == argv[1]) { Log::addConsoleLogger(Log::Info); } foreach (const QFileInfo &fi, fileInfos) { QFile f(fi.filePath()); if (f.open(QIODevice::ReadOnly)) { SchedulerConfig config = repo.parseConfig(&f, false); if (!config.isNull()) { QByteArray array; QBuffer buf(&array); buf.open(QIODevice::ReadWrite); qint64 size = config.writeAsPf(&buf); buf.seek(0); SchedulerConfig config2 = repo.parseConfig(&buf, false); QFile f1(fi.baseName()+".iteration1"); if (!f1.open(QIODevice::WriteOnly) || config.writeAsPf(&f1) < 0) { qDebug() << "cannot write file:" << f1.fileName() << ":" << f1.errorString(); success = false; } QFile f2(fi.baseName()+".iteration2"); if (!f2.open(QIODevice::WriteOnly) || config2.writeAsPf(&f2) < 0) { qDebug() << "cannot write file:" << f2.fileName() << ":" << f2.errorString(); success = false; } if (size > 0 && config.id() == config2.id()) { qDebug() << "ok" << fi.baseName() << config.id() << buf.size(); } else { qDebug() << "KO" << fi.baseName() << ": differs from output : original :" << config.id() << "dumped :" << config2.id() << buf.size() << ". diff -NubBw " << f1.fileName() << f2.fileName(); success = false; } } else { qDebug() << "warn" << fi.baseName() << ": invalid :" << f.errorString(); } } else { qDebug() << "KO" << fi.baseName() << ": cannot open :" << f.errorString(); success = false; } }
void ImageRepoTest::testRemove() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testRemove() begin"); ImageRepo repo("repotest", database, directory, false); ImageSpec spec; spec.purpose(Exposure::dark); std::set<ImageEnvelope> resultset = repo.get(spec); std::set<ImageEnvelope>::const_iterator ii; for (ii = resultset.begin(); ii != resultset.end(); ii++) { repo.remove(ii->id()); } debug(LOG_DEBUG, DEBUG_LOG, 0, "testRemove() end"); }
TEST(commit, time) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); Signature author = head.author(); ASSERT_EQ(author.time().time, 1448469335); time_t time = author.time().time; ASSERT_STREQ(std::ctime(&time), "Wed Nov 25 17:35:35 2015\n"); ASSERT_EQ(head.time(), 1448469351); time = head.time(); ASSERT_STREQ(std::ctime(&time), "Wed Nov 25 17:35:51 2015\n"); }
void ImageRepoTest::testImage() { debug(LOG_DEBUG, DEBUG_LOG, 0, "testImage() begin"); ImageSize size(360, 240); Image<RGB<float> > *image = new Image<RGB<float> >(size); ImagePtr imageptr(image); imageptr->setMetadata(FITSKeywords::meta("PURPOSE", "dark")); imageptr->setMetadata(FITSKeywords::meta("PROJECT", "testproject")); imageptr->setMetadata(FITSKeywords::meta("EXPTIME", 300.)); imageptr->setMetadata(FITSKeywords::meta("DATE-OBS", "2014-01-02T03:04:05.678")); imageptr->setMetadata(FITSKeywords::meta("INSTRUME", "SX")); imageptr->setMetadata(FITSKeywords::meta("CCD-TEMP", -47.1)); imageptr->setMetadata(FITSKeywords::meta("BAYER", "RGGB")); ImageRepo repo("repotest", database, directory, false); long imageid = repo.save(imageptr); debug(LOG_DEBUG, DEBUG_LOG, 0, "1st image saved: %d", imageid); // add the same image for times debug(LOG_DEBUG, DEBUG_LOG, 0, "uuid: %s", ((std::string)(imageptr->getMetadata("UUID"))).c_str()); imageptr->removeMetadata("UUID"); repo.save(imageptr); debug(LOG_DEBUG, DEBUG_LOG, 0, "2nd image saved"); imageptr->removeMetadata("UUID"); repo.save(imageptr); debug(LOG_DEBUG, DEBUG_LOG, 0, "3rd image saved"); imageptr->removeMetadata("UUID"); repo.save(imageptr); debug(LOG_DEBUG, DEBUG_LOG, 0, "4th image saved"); imageptr->removeMetadata("UUID"); repo.save(imageptr); debug(LOG_DEBUG, DEBUG_LOG, 0, "5th image saved"); debug(LOG_DEBUG, DEBUG_LOG, 0, "imageid = %ld", imageid); ImagePtr image2 = repo.getImage(imageid); CPPUNIT_ASSERT(image->getMetadata("PURPOSE") == image2->getMetadata("PURPOSE")); CPPUNIT_ASSERT(image->getMetadata("PROJECT") == image2->getMetadata("PROJECT")); CPPUNIT_ASSERT((double)image->getMetadata("EXPTIME") == (double)image2->getMetadata("EXPTIME")); CPPUNIT_ASSERT(image->getMetadata("DATE-OBS") == image2->getMetadata("DATE-OBS")); CPPUNIT_ASSERT(image->getMetadata("INSTRUME") == image2->getMetadata("INSTRUME")); CPPUNIT_ASSERT(image->getMetadata("BAYER") == image2->getMetadata("BAYER")); CPPUNIT_ASSERT((double)image->getMetadata("CCD-TEMP") == (double)image2->getMetadata("CCD-TEMP")); debug(LOG_DEBUG, DEBUG_LOG, 0, "testImage() end"); }
int main(int argc, char *argv[]) { try { Repository repo("test"); repo.init_repository("test"); } catch (const std::exception &e) { std::cout << e.what() << std::endl; } return 0; }
TEST(diff, differentCommits) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); // git diff HEAD..HEAD^^ Diff head_headupup_diff = head.getDiff(head.parent(0).parent(0)); ASSERT_EQ(head_headupup_diff.linesDeleted(), 4); ASSERT_EQ(head_headupup_diff.linesAdded(), 0); ASSERT_EQ(head_headupup_diff.filesChanged(), 3); // git diff HEAD^..HEAD^^ Diff headup_headupup_diff(head.parent(0), head.parent(0).parent(0)); ASSERT_EQ(headup_headupup_diff.linesDeleted(), 2); ASSERT_EQ(headup_headupup_diff.linesAdded(), 0); ASSERT_EQ(headup_headupup_diff.filesChanged(), 1); }
void RepoStmt::prepare(const std::string& sql) { finalize(); m_sql = sql; int rc = sqlite3_prepare_v2(m_repo.dbc(), sql.c_str(), sql.size(), &m_stmt, nullptr); if (rc != SQLITE_OK) { std::string errmsg = sqlite3_errmsg(m_repo.dbc()); if (rc == SQLITE_CORRUPT) { auto repoId = debugComputeRepoIdFromSQL(repo(), sql); reportDbCorruption(m_repo, repoId, "sqlite3_prepare_v2()"); } throw RepoExc("RepoStmt::%s(repo=%p) error: '%s' --> (%d) %s\n", __func__, &m_repo, sql.c_str(), rc, errmsg.c_str()); } }
void StructFieldValueTest::testEmptyStruct() { FixedTypeRepo repo(doc_repo, *doc_repo.getDocumentType(42)); const DataType &type = *repo.getDataType("test.header"); StructFieldValue value(type); // Serialize & equality std::unique_ptr<ByteBuffer> buffer(value.serialize()); buffer->flip(); CPPUNIT_ASSERT_EQUAL(buffer->getLength(), buffer->getLimit()); StructFieldValue value2(type); deserialize(*buffer, value2, repo); CPPUNIT_ASSERT(value == value2); }
void ofPackageManager::configurePackageManager(bool global) { auto configPath = ofFilePath::join(_cwdPath, "ofPackageManager.json"); std::string relativeOrAbsolute = "relative"; if (global) { configPath = ofFilePath::join(ofFilePath::getUserHomeDir(), ".ofPackageManager.json"); relativeOrAbsolute = "absolute"; } ofFile configFile(configPath); if (configFile.exists()) { ofLogWarning("config") << "Config file already exits."; if (!getBoolAnswer("Do you want to override it?")) { return; } } ofJson configJson; configJson["ofPath"] = getStringAnswer(relativeOrAbsolute + " path to openFrameworks?", ofFilePath::getAbsolutePath(getAbsolutePath("../../.."), false)); // configJson["pgPath"] = getStringAnswer(relativeOrAbsolute + " path to the executable of projectGenerator?", ofFilePath::join(configJson["ofPath"], "apps/projectGenerator/commandLine/bin/projectGenerator.app/Contents/MacOS/projectGenerator")); auto packagesPath = getStringAnswer("absolute path to packages directory?", ofFilePath::join(ofFilePath::getUserHomeDir(), ".ofPackages")); configJson["packagesPath"] = packagesPath; configJson["localAddonsPath"] = getStringAnswer("local addons directory?", "local_addons"); configFile.create(); configFile.open(configPath, ofFile::WriteOnly); configFile << configJson.dump(4); configFile.close(); if (ofDirectory::doesDirectoryExist(packagesPath, false)) { } else { ofxGit::repository repo(packagesPath); if (repo.clone("https://github.com/thomasgeissl/ofPackages.git")) { ofLogNotice("config") << "Successfully cloned packages database"; } else { ofLogError("config") << "Could not clone packages database"; } } }
TEST(commit, traversal) { Repository repo("../test/testrepo"); Commit head = repo.head().toCommit(); Commit& commit = head; const std::string expect[] = { "8f670e454b128d593b7bf9c1a80f46f8029818f9", "ea02e4840044d39a8889beb05c3ed7c97da41ec9", "8f9a04c7a15606e2bed98101a907ebd192c91428", "1a228f0e63ed64bc7d1c20946a28aef5ba2b4445" }; int i = 0; while (true) { EXPECT_EQ(commit.oid().toString(), expect[i++]); if (commit.parentCount() == 0) break; commit = commit.parent(0); } }
bool NucleiDetectionWholeSlideFilter::process() { std::shared_ptr<MultiResolutionImage> img = _input.lock(); std::vector<unsigned long long> dims = img->getLevelDimensions(this->_processedLevel); double downsample = img->getLevelDownsample(this->_processedLevel); _centerPoints.clear(); NucleiDetectionFilter<double> filter; filter.setAlpha(_alpha); filter.setBeta(_beta); filter.setHMaximaThreshold(_threshold); filter.setMaximumRadius(_maxRadius); filter.setMinimumRadius(_minRadius); filter.setRadiusStep(_stepRadius); std::vector<Point> tmp; for (unsigned long long t_y = 0; t_y < dims[1]; t_y += 512) { std::cout << t_y << std::endl; for (unsigned long long t_x = 0; t_x < dims[0]; t_x += 512) { Patch<double> tile = img->getPatch<double>(static_cast<unsigned long long>(t_x*downsample), static_cast<unsigned long long>(t_y*downsample), 512, 512, this->_processedLevel); double* buf = tile.getPointer(); filter.filter(tile, tmp); for (std::vector<Point>::const_iterator it = tmp.begin(); it != tmp.end(); ++it) { std::vector<float> curPoint; curPoint.push_back(it->getX() * downsample + t_x*downsample); curPoint.push_back(it->getY() * downsample + t_y*downsample); _centerPoints.push_back(curPoint); } tmp.clear(); } } if (!_outPath.empty()) { std::shared_ptr<Annotation> annot(new Annotation()); annot->setName("Detected nuclei"); annot->setType(Annotation::POINTSET); for (std::vector<std::vector<float> >::const_iterator it = _centerPoints.begin(); it != _centerPoints.end(); ++it) { float x = (*it)[0]; float y = (*it)[1]; annot->addCoordinate(Point(x, y)); } std::shared_ptr<AnnotationList> annotList(new AnnotationList()); annotList->addAnnotation(annot); XmlRepository repo(annotList); repo.setSource(_outPath); repo.save(); } return true; }